Browse Source

add null check to itemvirtualizer simple

Dan Walmsley 6 years ago
parent
commit
79ecf98a46
1 changed files with 7 additions and 4 deletions
  1. 7 4
      src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs

+ 7 - 4
src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs

@@ -295,11 +295,14 @@ namespace Avalonia.Controls.Presenters
         /// <inheritdoc/>
         public override void ScrollIntoView(object item)
         {
-            var index = Items.IndexOf(item);
-
-            if (index != -1)
+            if(Items != null)
             {
-                ScrollIntoView(index);
+                var index = Items.IndexOf(item);
+
+                if (index != -1)
+                {
+                    ScrollIntoView(index);
+                }
             }
         }