Browse Source

Check for null VirtualizingPanel.

The panel may not have been created when the virtualization mode is changed - handle that. Fixes #634.
Steven Kirk 9 years ago
parent
commit
d4f24402c5
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/Avalonia.Controls/Presenters/ItemVirtualizer.cs

+ 6 - 2
src/Avalonia.Controls/Presenters/ItemVirtualizer.cs

@@ -185,8 +185,12 @@ namespace Avalonia.Controls.Presenters
         /// <inheritdoc/>
         public virtual void Dispose()
         {
-            VirtualizingPanel.Controller = null;
-            VirtualizingPanel.Children.Clear();
+            if (VirtualizingPanel != null)
+            {
+                VirtualizingPanel.Controller = null;
+                VirtualizingPanel.Children.Clear();
+            }
+
             Owner.ItemContainerGenerator.Clear();
         }