Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF TreeView and Disabled Item

Tags:

c#

wpf

I have a WPF TreeView with some of the items disabled - IsEnabled = false.

When I click on the disabled item, the parent item gets selected (I don't like this). I want to stay on the current item when some disabled item is clicked. Is this possible and how?

like image 720
Dusan Avatar asked Feb 13 '26 05:02

Dusan


1 Answers

Bind IsHitTestVisible to IsEnabled. Something like this:

<Style TargetType="TreeViewItem">
    <Setter Property="IsHitTestVisible" Value="{Binding IsEnabled}" />
</Style>
like image 151
LPL Avatar answered Feb 15 '26 19:02

LPL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!