Skip to content
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

Question: SelectedItemChanged in TreeView #1334

Closed
ac-lap opened this issue Sep 14, 2019 · 7 comments
Closed

Question: SelectedItemChanged in TreeView #1334

ac-lap opened this issue Sep 14, 2019 · 7 comments
Assignees
Labels
duplicate This issue or pull request already exists question

Comments

@ac-lap
Copy link

ac-lap commented Sep 14, 2019

There is no SelectedItemChanged event in the TreeView, the WinForm one has this event. What is the alternative for it in UWP.
I need this event to give a summary of all the items selected by the user, plz suggest someway to achieve this.

@robloo
Copy link
Contributor

robloo commented Sep 14, 2019

I've never used TreeView as I'm waiting for it to stabilize some more. However, TreeViewItem derives from SelectorItem and even ListViewItem. This means it has an IsSelected dependency property. You could hookup a callback to this property and handle it manually. This is easiest if you are also manually adding items to the TreeView already.

This should be feature request too. There are a lot of events standard in other repeater/selection controls that seem to be missing.

@ac-lap
Copy link
Author

ac-lap commented Sep 15, 2019

No, I am not adding the items manually. I am using data binding. Given the TreeView does not even give the list of items, how can I hook a callback?

@robloo
Copy link
Contributor

robloo commented Sep 16, 2019

You might want to take a look at the second reply from Nico Zhu here:
https://stackoverflow.com/questions/56766785/uwp-get-selected-nodes-from-treeview-control

If you create your own view model class with an IsSelected property you can bind it in the data template of the TreeViewItem. Then your model itself will be reporting this information and you could hook up an event to it (but you will have to add an event to to your view model classes).

@jevansaks
Copy link
Member

We recently noticed this oversight as well. @kaiguo did you have another bug tracking this or should we turn this into it?

@kaiguo
Copy link
Contributor

kaiguo commented Sep 16, 2019

@jevansaks Yeah we have #322. Should we just close this one and use the other one to track?

@jevansaks
Copy link
Member

Yes, I'll mark this as dupe.

@jevansaks jevansaks added the duplicate This issue or pull request already exists label Sep 16, 2019
@beatnikthedan
Copy link

how would I do this with SelectedItemsChanged? i'm trying to keep track of selected items. right now I'm doing it from a Tapped event on the treeview and have to loop through the entire treeview and figure out what is checked in my treeview and what is checked in my model that the nodes are bound to. if I bind to IsSelected it only works for single selection not multiple selection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists question
Projects
None yet
Development

No branches or pull requests

5 participants