I have wpf TreeView -- bound to some data. The Treeview resides on the left hand of a window divided into two areas where the tree is the navigation and a panel on the right side changes content depending on the tree node selected.
Not all the nodes of the treeview produce detail information. I want to disable the selection of those nodes. Any idea?
Thanks
Do you have something like a boolean property in your source called
HasDetails
or something? In that case you can use something like this. Create a MultiDataTrigger in the ItemContainerStyle that binds toHasDetails
in the DataContext andIsSelected
for theTreeViewItem
and if both are True (well, True that HasDetails is False:-), you start a Storyboard that "unselects" the newly selectedTreeViewItem
.This will disable selection for all the
TreeViewItem
's that doesn't have details but they will still be expandable. Hopefully that was what you were looking forUpdate
To disable the
TreeViewItem
's where HasDetails is False you can use this