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
25.91k stars 2.24k forks source link

TreeView.SelectionChanged event not fired when invoking UnselectAll #17486

Open AngryCarrot789 opened 1 day ago

AngryCarrot789 commented 1 day 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 day 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