Reputation: 5325
I have developed WPF application which contains the menuitem.
I set background color to these menuitem using the following code-
<MenuItem Header="_Main" >
<MenuItem Header=" _Daily Expences">
<MenuItem.Background >
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0" Color="DeepSkyBlue" />
<GradientStop Offset="1" Color="DarkOliveGreen" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</MenuItem.Background>
</MenuItem>
<Separator ></Separator>
<MenuItem Header=" _Business">
<MenuItem.Background >
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0" Color="DeepSkyBlue" />
<GradientStop Offset="1" Color="DarkOliveGreen" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</MenuItem.Background>
</MenuItem>
</MenuItem>
When i run the application it shows the color which i set, but the background color for this menu list is still gray when i focus the cursor on the menuitem.
Please help me to solve this problem.
Upvotes: 1
Views: 3420
Reputation: 3513
I think you should use MenuItem.ItemContainerStyle
take a look at the answer here (for me it should be the same problem): changing background color of container when textbox is in focus
Upvotes: 1