-
Notifications
You must be signed in to change notification settings - Fork 679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not possible to select treeview nodes programmatically #386
Comments
@kaiguo Is this something you fixed recently or is it part of the pending PR you have out? |
SelectedNoes collection only works in multi-select mode, @knightmeister can you set TreeView to multi-select and see if it still repros? We are working on adding a new SelectedNode property for single selection, see PR #243. |
Shouldn't we make SelectedNodes contain the one and only selected item in single select? I'm pretty sure Selector.SelectedItems works this way. |
@jevansaks Yeah I think that works, then we can probably just get rid of the singular form SelectedItem and SelectedNode? |
@kaiguo Yes, it works when SelectionMode=Multiple. |
No, having the singular one is still convenient when in single select mode. |
I see. I'll make some updates in #243 |
Ok, i'll assign this to you then. |
Just wanted to chime in and ask if there's any progress on this? I really need to be able to programmatically set the selected item |
Hey @dpaulino, sorry I've been working on rounded corners stuff. Will get back to this some time next week hopefully. |
* Add IsContentMode on TreeViewList * Add SelectedNode * Add TreeViewSelectedNodeTest * Add SelectedItem * Refactor * Add SelectedItem test * Fix tests * Add SelectedItems * Update ViewModel * Update tests * Remove unused code * Add ItemFromNode * Add comments * Skip tests on lower os versions * Update null checks * Update tests * Cleanups * Update ItemFromNode * Ignore m_originalNode when updating selection * Update NodeFromItem * Update ViewModel reference to be weak ref * Add GetViewModel * Update weak refs * Set the new apis to preview * Fix #386 * Fix NodeFromItem * Fix test * Cleanups * Fix single selection * Cleanups * More cleanups
🎉This issue was addressed in #243, which has now been successfully released as Handy links: |
@kaiguo hey, just wanted to triple check. With your PR regarding this, should I now be use TwoWay binding for
|
Yes, you can use binding like that for single selection. |
Okay thanks for confirming. I think I'm getting an access violation error when I use two way binding though... But I'll try to get a proper repro, and I'll create a new issue if I see any issues |
Describe the bug
Previous Windows tree views had properties such as SelectedNodes which allowed you to set the nodes which are selected/highlighted in the control.
The UWP treeview exposes a
SelectedNodes
property which is a collection. The collection is read only and calling.Add
on it and specifying a TreeViewNode does not add it to the collection and does not select the item in the user interface.An IsSelected property should also be added to
TreeViewNode
to match withTreeViewItem
.Steps to reproduce the bug
Add items to a TreeView and then use the following code, which you would expect would select the first item.
SelectedNodes = 0
Expected behavior
The first tree node would be selected.
Version Info
1809
The text was updated successfully, but these errors were encountered: