title: WPF ContextMenu Style structure
body: <p>I would like to restyle a <code>ContextMenu</code>, but I have a question about how to structure my Xaml.</p>
  
  <p>In my application resources, I have something like this:</p>
  
  <pre><code>&lt;ControlTemplate TargetType="MenuItem" x:Key="MenuItemTemplate"&gt;
      ...
  &lt;/ControlTemplate&gt;
  
  &lt;ControlTemplate TargetType="ContextMenu" x:Key="ContextMenuTemplate"&gt;
      &lt;ControlTemplate.Resources&gt;
          &lt;Style TargetType="{x:Type MenuItem}"&gt;
              &lt;Setter Property="Template" Value="{StaticResource MenuItemTemplate}" /&gt;
          &lt;/Style&gt;
      &lt;/ControlTemplate.Resources&gt;
  
      ...    
  
  &lt;/ControlTemplate&gt;
  
  &lt;Style TargetType="{x:Type ContextMenu}" x:Key="RadialContextMenu"&gt;
      &lt;Setter Property="Template" Value="{StaticResource ContextMenuTemplate}" /&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>This seems to work fine, context menus with the <code>ContextMenuTemplate</code> style have styled menu items, and other context menus are unaffected, without having to set a style explicitly on any <code>MenuItems</code>.</p>
  
  <pre><code>&lt;ContextMenu x:Name="menu" Style="{StaticResource RadialContextMenu}"&gt;
      &lt;MenuItem Header="Foo"/&gt;
      &lt;MenuItem Header="Bar"/&gt;
  &lt;/ContextMenu&gt;
  </code></pre>
  
  <p>However, I don't like having that <code>ControlTemplate.Resources</code> section. I'd much rather have it for example inside the <code>x:Key="RadialContextMenu"</code> style, so that both of the control templates are "clean".</p>
  
  <p>How can I move the Style element out of the second <code>ControlTemplate</code>?</p>