Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextBlock Style Setter for the Cursor property

I want to change cursor style when mouse is over the WPF TextBlock.

<Style TargetType="{x:Type TextBlock}" x:Key="HoverBox">
     <Style.Triggers>
           <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="Yellow" />
                <Setter Property="Cursor" Value="Hand" />   
           </Trigger>
     </Style.Triggers>
</Style> 

The problem is that <Setter Property="Cursor" Value="Hand" /> doesn't work.

But this Setter works fine <Setter Property="Foreground" Value="Yellow" />

Also I need to use underlying font style. How I can do it?

Thanks!!

like image 357
Friend Avatar asked Nov 05 '25 15:11

Friend


1 Answers

Maybe you have a precedence problem? e.g. when you set the cursor on the styled control the trigger will not have enough precedence to change the value.

(If i apply this style to a TextBlock which only has its Text set it works just fine)

like image 83
H.B. Avatar answered Nov 08 '25 14:11

H.B.