Disable WPF TreeView (or TreeViewItem) selection?

Shimmy Weitzhandler picture Shimmy Weitzhandler · Dec 29, 2010 · Viewed 18.2k times · Source

Is there a nice way (except retemplating the whole TreeViewItem.Template) to disable selection in TreeView?

I am basically looking for the ItemsControl style of the TreeView (An ItemsControl is the best use to 'disable' selection on ListBox, read this post)

Answer

Morten Strand picture Morten Strand · Nov 27, 2013

Try this:

<Trigger Property="HasItems" Value="true">
   <Setter Property="Focusable" Value="false" />
</Trigger>