Skip to content

Commit 3aa4967

Browse files
authored
Fixing out of range exception on tree view (#3574)
This occurs when IsExpanded is set on a virtualized container that has been removed. Fixes #3572
1 parent e163c82 commit 3aa4967

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/MaterialDesignThemes.Wpf/TreeListView.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ internal void ItemExpandedChanged(TreeListViewItem item)
8484
if (InternalItemsSource is { } itemsSource)
8585
{
8686
int index = ItemContainerGenerator.IndexFromContainer(item);
87+
//Issue 3572
88+
if (index < 0) return;
8789
var children = item.GetChildren().ToList();
8890
bool isExpanded = item.IsExpanded;
8991
itemsSource.SetIsExpanded(index, isExpanded);

0 commit comments

Comments
 (0)