I need to change the cursor of a TreeViewItem in a trigger. This code works for all other properties but not Cursor:
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="QuickPhrases:TreeViewChecker.IsMouseDirectlyOverItem"
Value="True">
</Condition>
<Condition Property="CanSelect" Value="True"></Condition>
</MultiTrigger.Conditions>
<Setter Property="BorderThickness" Value="0,0,0,1" />
<Setter Property="BorderBrush" Value="Blue" />
<Setter Property="Cursor" Value="Hand"></Setter>
<Setter Property="Foreground" Value="Blue"></Setter>
</MultiTrigger>
</Style.Triggers>
What gives, and also, how do I do it correctly?
You are doing it correctly, it should just work. In fact I'm unable to reproduce your issue via the following steps:
TargetType="TreeViewItem"
.Well, this is just working fine, i.e. once hovering over a TreeViewItem the cursor gets triggered to whatever value I chose in the trigger, be it 'Hand' or 'Wait' or else.
One important detail though: the cursor only appears while hovering directly over the header, i.e. not the entire row (this is consistent with WPF TreeViewItem row behavior though, see here for a related example regarding row highlighting). Especially the cursor does not appear when the TeeViewItem header is empty! Have you supplied any data for the headers yet?
Otherwise their must be something weird going on behind the scenes in your project/environment? Have you tried a simple repro case like this already?
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