Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This example shows how to use Trigger elements to style a MenuItem in a ContextMenu.
A Style is created that changes the appearance of a MenuItem in response to events that are raised on the item. When you move the mouse over the item, the foreground color and font characteristics change.
Example
<Style x:Key="Triggers" TargetType="{x:Type MenuItem}">
<Style.Triggers>
<Trigger Property="MenuItem.IsMouseOver" Value="true">
<Setter Property = "FontSize" Value="16"/>
<Setter Property = "FontStyle" Value="Italic"/>
<Setter Property = "Foreground" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
For the complete sample, see ContextMenu Styles Sample.