AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
26.06k stars 2.25k forks source link

TreeView.SelectionChanged event not fired when invoking UnselectAll #17486

Open AngryCarrot789 opened 1 week ago

AngryCarrot789 commented 1 week ago

Describe the bug

When I call UnselectAll on my tree view, the selected items list gets called but no event is fired.

To Reproduce

Create a TreeView and fill it with some TreeViewItems. Then select an item and invoke UnselectAll, you will notice no SelectionChanged event is fired

Expected behavior

No response

Avalonia version

11.2.999-cibuild0048720-alpha

OS

Windows

Additional context

I insert TreeViewItems into the TreeView manually: this.Items.Insert(0, new TreeViewItem());. Maybe there is an issue with this technique?

AngryCarrot789 commented 1 week ago

Seems like the TreeView.SelectedItemsCollectionChanged method in the NotifyCollectionChangedAction.Reset case is checking if SelectedItems list has items which it wont since it's responding to a CollectionChanged event from said list