MultiSelectTreeView
MultiSelectTreeView copied to clipboard
Expanded node event
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.
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?
Do you have a link where I can read in this? Thanks a lot!
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.
Thank you. I will give it a try. I will give you feedback if it does not work.
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.