How to: Use Triggers to Style a CheckBox
This example shows how to use Trigger elements to style a CheckBox control.
Example
The following example creates a style that changes the appearance of a CheckBox in response to events that are raised on the control. When you move the mouse pointer over the CheckBox, the Background color changes and if you select the CheckBox, the Foreground color changes.
<Style x:Key="Triggers" TargetType="{x:Type CheckBox}">
<Style.Triggers>
<Trigger Property="CheckBox.IsPressed" Value="true">
<Setter Property = "Foreground" Value="Green"/>
</Trigger>
<Trigger Property="CheckBox.IsMouseOver" Value="true">
<Setter Property = "Background" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
For the complete sample, see CheckBox Styles Sample.
See Also
Tasks
How to: Create a CheckBox
How to: Include an Image in a CheckBox