diff --git a/src/Avalonia.Controls.TreeDataGrid/Selection/TreeSelectedItems.cs b/src/Avalonia.Controls.TreeDataGrid/Selection/TreeSelectedItems.cs index 19494388..ee25a7b3 100644 --- a/src/Avalonia.Controls.TreeDataGrid/Selection/TreeSelectedItems.cs +++ b/src/Avalonia.Controls.TreeDataGrid/Selection/TreeSelectedItems.cs @@ -56,7 +56,8 @@ public T? this[int index] { for (var i = range.Begin; i <= range.End; ++i) { - yield return node.ItemsView![i]; + if (node.ItemsView is not null) + yield return node.ItemsView[i]; } } @@ -110,4 +111,4 @@ public TreeSelectedItems(TreeSelectionModelBase root) : base(root) { } yield return i; } } -} \ No newline at end of file +}