unoplatform / uno

Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
https://platform.uno
Apache License 2.0
8.62k stars 696 forks source link

TreeView selection issues #15638

Open weitzhandler opened 4 months ago

weitzhandler commented 4 months ago

Current behavior

TreeView has some quirks with selection when SelectionMode is set to Multiple when adding items to the SelectedItems collection:

  1. You'd think that the individual TreeViewItem.IsSelected properties are set to true but they're not.
  2. The SelectionChanged event is not fired.

Expected behavior

The 3 selection points of the TreeView should all be synced, and the SelectionChanged should be raised once (not less but not more) for any selection change to any one of them.

  1. SelectedItem/SelectedItems
  2. SelectedNode/SelectedNodes
  3. TreeViewItem.IsSelected

How to reproduce it (as minimally and precisely as possible)

https://github.com/weitzhandler/TreeViewSelectionRepro

Workaround

Traverse entire tree and explicitly set each TreeViewItem.IsSelection individually to desired selection value.

Works on UWP/WinUI

No

Environment

No response

NuGet package version(s)

No response

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

This is a WinUI issue and has been reported there as well:

https://github.com/microsoft/microsoft-ui-xaml/issues/125 https://github.com/microsoft/microsoft-ui-xaml/issues/5738

nickrandolph commented 4 months ago

Related WinUI issues: https://github.com/microsoft/microsoft-ui-xaml/issues/5738 https://github.com/microsoft/microsoft-ui-xaml/issues/125