Skip to content
This repository has been archived by the owner on May 7, 2022. It is now read-only.

Expanded node event #38

Open
Quantentunnel opened this issue Feb 7, 2017 · 5 comments
Open

Expanded node event #38

Quantentunnel opened this issue Feb 7, 2017 · 5 comments

Comments

@Quantentunnel
Copy link

First of all: Thank you for this great project. This ticket is not an issue, in fact it´s a feature request.

It would be nice if there would be an event which triggers when a node has been expanded (and not been selected). So the event should also trigger if the user clicks on the triangle beside the display name. Currently it is only possible to check if a node is expanded or not.

@ygoe
Copy link
Owner

ygoe commented Feb 7, 2017

You can bind this view property to your view-model class and react on the property changed. That's how I do it, also for implementing lazy loading of child items. Does that help you or do you need more details?

@Quantentunnel
Copy link
Author

Do you have a link where I can read in this? Thanks a lot!

@ygoe
Copy link
Owner

ygoe commented Feb 25, 2017

I use that in my TxEditor application, you can view its source code here. The TreeViewItemViewModel class is a base class for all view models that are used as tree items. It has the IsExpanded property which is bound to the MultiSelectTreeViewItem.IsExpanded property in the MultiSelectTreeView.ItemContainerStyle in the XAML file (go the the "region Tree view"). Whenever the control's expanded state changes, the view model property is updated. You can add your code to the property setter there, like I do here for lazy loading.

@Quantentunnel
Copy link
Author

Thank you. I will give it a try.
I will give you feedback if it does not work.

@danlyons-home
Copy link

It might still be useful to have an expanded event, much like the standard TreeView has.

In the original, it is implemented as a RoutedEvent on the item type which can bubble, and it allows users to set up a centralized event handler for any tree item expanding by adding a TreeViewItem.Expanded attribute on the TreeView element in the XAML.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants