In a WPF form, I have the following TextBlock. When I move my mouse over it, I would like to see the text of the TextBlock underlined. How can I do that? I tried with TextBlock.Triggers, but it didn't work.
Thanks!
Use a style:
<TextBlock Text="Hurrah">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="TextDecorations" Value="Underline" />
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
(Style shown inline for brevity; extract into a resource if you're planning to reuse it.)
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