MaterialDesignInXamlToolkit icon indicating copy to clipboard operation
MaterialDesignInXamlToolkit copied to clipboard

How do I get the data in a TreeListView control when multiple items are selected?

Open Qianzujin opened this issue 2 months ago • 2 comments

How do I get the data in a TreeListView control when multiple items are selected?

Qianzujin avatar Nov 15 '25 12:11 Qianzujin

@Qianzujin since the TreeListView inherits from the WPF-native ListView, you can just access the SelectedItems property of the ListView. If u want to use the MVVM pattern and bind the SelectedItems you have to use one of the workarounds (attached property or eventhandler in the code behind) like described here: https://stackoverflow.com/questions/31176949/binding-selecteditems-of-listview-to-viewmodel

There is an open PR for supporting binding for the SelectedItems, however that needs more work done to it, see #3849

corvinsz avatar Nov 16 '25 14:11 corvinsz

One other common option is to add an IsSelected property to each of your items in the tree view and then bind the IsSelected property of the item to that property. Then you can access it from your view model.

Keboo avatar Nov 16 '25 14:11 Keboo