Wednesday, 16 February 2011

MouseOver Triggers

Here is a minimal example of changing the background colour of a TextBlock when MouseOver is detected.
<Window.Resources>
<Style TargetType="TextBlock">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Pink" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<StackPanel>
<TextBlock>Hello World</TextBlock>
</StackPanel>