MultiSelectTreeView icon indicating copy to clipboard operation
MultiSelectTreeView copied to clipboard

Expanded node event

Open Quantentunnel opened this issue 8 years ago • 5 comments

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.

Quantentunnel avatar Feb 07 '17 08:02 Quantentunnel

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?

ygoe avatar Feb 07 '17 20:02 ygoe

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

Quantentunnel avatar Feb 25 '17 18:02 Quantentunnel

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.

ygoe avatar Feb 25 '17 18:02 ygoe

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

Quantentunnel avatar Feb 25 '17 21:02 Quantentunnel

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.

danlyons-home avatar May 02 '17 17:05 danlyons-home