title: WPF Submenu styling
body: <p>If I add a submenu to a menu item, then the submenu is not being styled properly.  One can only style the menuitem at this point, and not the actual sub menu. Hence one can't replace the <code>IsMouseOver</code> styling which then just defaults to whatever theme is enabled on windows.</p>
  <p>How can one style the submenu?</p>
  <hr />
  <pre><code>    &lt;Style TargetType=&quot;{x:Type MenuItem}&quot;&gt;
          &lt;Setter Property=&quot;Background&quot; Value=&quot;#0f3c5a&quot;&gt;&lt;/Setter&gt;
          &lt;Setter Property=&quot;Foreground&quot; Value=&quot;White&quot;&gt;&lt;/Setter&gt;
          &lt;Style.Triggers&gt;
              &lt;Trigger Property=&quot;IsHighlighted&quot; Value=&quot;True&quot;&gt;
                  &lt;Setter Property=&quot;Background&quot; Value=&quot;Black&quot;&gt;&lt;/Setter&gt;
              &lt;/Trigger&gt;
              &lt;Trigger Property=&quot;IsEnabled&quot; Value=&quot;False&quot;&gt;
                  &lt;Setter Property=&quot;Foreground&quot; Value=&quot;LightGray&quot;&gt;&lt;/Setter&gt;
              &lt;/Trigger&gt;
          &lt;/Style.Triggers&gt;
      &lt;/Style&gt;
      &lt;Style TargetType=&quot;{x:Type ContextMenu}&quot;&gt;
          &lt;Setter Property=&quot;OverridesDefaultStyle&quot; Value=&quot;True&quot;/&gt;
          &lt;Setter Property=&quot;SnapsToDevicePixels&quot; Value=&quot;True&quot;/&gt;
          &lt;Setter Property=&quot;Template&quot;&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType=&quot;{x:Type ContextMenu}&quot;&gt;
                      
                      &lt;!--Here is where you change the border thickness to zero on the menu--&gt;
                      &lt;Border BorderThickness=&quot;0&quot; x:Name=&quot;Border&quot;  &gt;
                       &lt;StackPanel ClipToBounds=&quot;True&quot; Orientation=&quot;Vertical&quot;
                       IsItemsHost=&quot;True&quot;/&gt;
                       &lt;/Border&gt;
                      &lt;ControlTemplate.Triggers&gt;
                          &lt;Trigger Property=&quot;IsMouseOver&quot; Value=&quot;true&quot;&gt;
                              &lt;Setter TargetName=&quot;Border&quot; Property=&quot;Background&quot; Value=&quot;#5082a4&quot; /&gt;
                          &lt;/Trigger&gt;
                      &lt;/ControlTemplate.Triggers&gt;
            &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
        &lt;/Setter&gt;
      &lt;/Style&gt;
  </code></pre>
  <p>and then something like this for the menu</p>
  <pre><code>&lt;ContextMenu Closed=&quot;ContextMenu_Closed&quot;  &gt;
      &lt;MenuItem  Command=&quot;k:Window1.NewCommand&quot; &gt; 
         &lt;MenuItem  Command=&quot;k:Window1.DeleteCommand&quot;/&gt; 
      &lt;/MenuItem&gt;
      ...
  </code></pre>
  <p>Everything on the NewCommand layer is styled properly, going inside NewCommand to view DeleteCommand the MenuItem itself is styled properly, but the actual menu is defaulting to the Windows theme styling and I see no way over overwriting that so far.  The most important part is to get the IsMouseOver of submenu's to maintain the same look and feel as the main menu structure.</p>