I have a two-level hierarchy displayed in a WPF TreeView, but I only want the child nodes to be selectable - basically the top level nodes are for categorisation but shouldn't be selectable by themselves.
Can I achieve this?
Thanks...
Define styles for each type of items, like Bijington wrote. for non-selectable nodes set the Focusable-Property of the container (TreeViewItem for TreeViews) to false.
To do so you would need to override the style for treeview. Ideally you will have two types of treeview items one for your top-level nodes (im assuming folders) and another simply for the children, then you should be able to define how each item type in the tree behaves. So create a style for each item type, then for the folder node simply change the trigger for is selected to do nothing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With