Replies: 7 comments
-
@grokys The current implementation of TreeView in WinUI was built before ItemsRepeater/SelectionModel was available so it does not use it. TreeView's multiselection does behave to get automatic selection of non-leaf nodes. Are you thinking of a different TreeView ? |
Beta Was this translation helpful? Give feedback.
-
I'm thinking of a Here, selecting
|
Beta Was this translation helpful? Give feedback.
-
I see. Yes currently this is not exposed and the default is a tristate, but this seems like a reasonable thing to do. SelectionNode::IsSelected returns true/false based on its selection and we also have SelectionNode::IsSelectedWithPartial which is what is currently used. Perhaps it just needs to be exposed though SelectionModel. SelectionChanged args will also need to differentiate between the two perhaps. |
Beta Was this translation helpful? Give feedback.
-
Thanks! I put together a quick hack in our Avalonia port which added a property AvaloniaUI/Avalonia@9b77a73 That seems to work from my initial messing around, but I suspect there's more to it. TBH by this point I'd given up in keeping a semblance of compatibility between WinUI and Avalonia and was just modifying stuff willy-nilly ;) However if possible I'd like to maintain some level of API compatibility between the two. I'll revisit this soon and try to come up with a decent proposal. In the meantime if you have any feedback on the commits above, let me know! |
Beta Was this translation helpful? Give feedback.
-
Thanks. Please keep these feedback issues coming. SelectionModel is still in preview and we can make api updates as needed. As you are already aware, most of the team is focused on WinUI3 so we won't be able to get to these until then. |
Beta Was this translation helpful? Give feedback.
-
@grokys Excited to see a proposal on this. As Ranjesh said, SelectionModel is slightly flexible as its still in preview so your feedback comes at a good time - this seems like a good thing to implement for the WinUI TreeView. I'll circle back when we may have more capacity to look into this! |
Beta Was this translation helpful? Give feedback.
-
Thanks @anawishnoff for the feedback. I've implemented this functionality in the Avalonia port of |
Beta Was this translation helpful? Give feedback.
-
Discussion: SelectionModel and TreeViews
I notice that
SelectionModel
's support for hierarchical data is based on a "checkbox" model where a non-leaf node is considered selected if all of its children are selected, that is:IsSelected(0) == null
when some but not all children are selectedIsSelected(0) == true
when all children are selectedNote that in this example, "Root" was never selected explicitly.
This is great for a tree of checkboxes, but this isn't how a multi-selectable
TreeView
works, where a user must select each node with a click etc.I notice that WinUI's
TreeView
doesn't useSelectionModel
: is that becauseSelectionModel
isn't designed for this use-case? Should it be?Beta Was this translation helpful? Give feedback.
All reactions