As shown in the snapshot below, the style
I used in my following XAML
successfully changed the default background and foreground color of menu items to blue and white respectively. But on mouse over, it does not change the background color
of the MenuItem
to light blue (instead, it keeps the default color of mouse over). What I may be missing here, and how can we fix the issue? I tried solutions to this and this post but still no luck.
Snapshot of the menu
<Menu>
<MenuItem Header="_File" Background="{DynamicResource MahApps.Brushes.Accent}" Width="32" Height="30">
<MenuItem.Resources>
<Style BasedOn="{StaticResource MahApps.Styles.MenuItem}" TargetType="MenuItem">
<Setter Property="Background" Value="{StaticResource MahApps.Brushes.Accent}"/>
<Setter Property="Foreground" Value="{StaticResource MahApps.Brushes.IdealForeground}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type MenuItem}">
<Grid Background="{TemplateBinding Background}">
<MenuItem Header="{TemplateBinding Header}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{StaticResource MahApps.Brushes.Badged.Background}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</MenuItem.Resources>
<MenuItem Header="_New" />
<MenuItem Header="_Open" />
<MenuItem Header="_Save" />
<Separator />
<MenuItem Header="_Exit" />
</MenuItem>
</Menu>
UPDATE
I have uploaded this very basic WPF sample project here - in case someone wants to test his/her suggestion. This file upload link will expire in 30 days.