0

It seems that the menuitem style that I am attempting to use gets totally overwritten when I use ItemContainerStyle.

Here's an example of what happens when I use it:

enter image description here

However, when I don't use it, this is what I get:

enter image description here

I much prefer the look of the second menu, but it doesn't support dynamic menu creation due to not using ItemContainerStyle. What could possibly be overwriting the style? I'm using Mahapps Dark base and VS colors/styles.

Fruchtzwerg
  • 10,999
  • 12
  • 40
  • 49
TheKitchenSink
  • 136
  • 1
  • 9
  • Have you tried the [BasedOn](https://stackoverflow.com/questions/3656814/how-to-inherit-xaml-style-and-override-property-of-child-element) attribute on the `ItemContainerStyle` `Style`? – Massimiliano Kraus Jun 09 '17 at 08:35

2 Answers2

1

you should use BaseOn property in the ItemContainerStyle.

<ItemContainerStyle x:Key="MyContainerStyle" BaseOn="{DynamicResource MenuItemStyle}">Style here</ItemContainerStyle>
Sokheang Khun
  • 137
  • 1
  • 2
  • 11
1

Base your custom Style on the MetroMenuItem style that comes with MahApps:

<Style TargetType="MenuItem" BasedOn="{StaticResource MetroMenuItem}">
    <Setter Property="Background" Value="Yellow" />
</Style>
mm8
  • 163,881
  • 10
  • 57
  • 88
  • Thanks for the answer! I set up my project to use MahApps in the app.xaml, so the styles would be global. Any clue why this wouldn't automatically base off of that? – TheKitchenSink Jun 15 '17 at 03:53
  • Why would it be? That's not how implicit style works. – mm8 Jun 15 '17 at 10:00