menu style

Jan 19, 2009 at 3:50 PM
How can I create a style for a menu and menu item? Can anyone show me a XAML example? Thaks.
Coordinator
Jan 19, 2009 at 7:52 PM
Sure.  Here is a quick example of just changing Backgrounds.  I just threw this together in XamlPad so if you need something more complex just ask.

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<Page.Resources>
<Style x:Key="YellowMIBG" TargetType="MenuItem">
 <Setter Property="Background" Value="Yellow"/>
</Style>
<Style x:Key="BlueMIBG" TargetType="MenuItem">
 <Setter Property="Background" Value="Blue"/>
</Style>
<Style x:Key="PurpleMBG" TargetType="Menu">
 <Setter Property="Background" Value="Purple"/>
</Style>
</Page.Resources>
<Menu Style="{StaticResource PurpleMBG}">
 <MenuItem Header="File">
  <MenuItem Header="Hello World" Style="{StaticResource YellowMIBG}"/>
  <MenuItem Header="World, Hello" Style="{StaticResource BlueMIBG}"/>
 </MenuItem>
</Menu>
</Page>
Jan 21, 2009 at 7:30 AM

Thank you very much.

How do you change other properties - for example the color of text and background on mouse over?