title: WPF Menu Item with Button
body: <p>How can I add a <code>Button</code> to the menu items shown in the image below? I've tried creating a <code>MenuItem</code> template but when i use that the Header text of the menu item no longer displays what Binding am I doing wrong here?</p>
  
  <p>Not using menuitem template</p>
  
  <p><a href="https://i.stack.imgur.com/7pIiM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7pIiM.png" alt="enter image description here"></a></p>
  
  <p>Using Menu Item Template which is currently commented out in the code:</p>
  
  <p><a href="https://i.stack.imgur.com/M5rz5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M5rz5.png" alt="enter image description here"></a></p>
  
  <p>I would prefer it looks like this using a label as the text and a <code>Button</code>.</p>
  
  <p><a href="https://i.stack.imgur.com/ihq8O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ihq8O.png" alt="enter image description here"></a></p>
  
  <p></p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;XmlDataProvider x:Key="MockList"   XPath="/MockObjects/*" &gt;
          &lt;x:XData &gt;
              &lt;MockObjects xmlns=""&gt;
                  &lt;MockObject  Name="Louis" Type="A" Number="1" /&gt;
                  &lt;MockObject Name="Joseph Angelo" Type="A" Number="2" /&gt;
                  &lt;MockObject Name="Papineau Philadelphia" Type="B" Number="301" /&gt;
                  &lt;MockObject  Name="Mary" Type="B" Number="4" /&gt;
                  &lt;MockObject Name="Kevin" Type="C" Number="5" /&gt;
                  &lt;MockObject Name="Sarah" Type="D" Number="6" /&gt;
                  &lt;MockObject  Name="Doug" Type="E" Number="7" /&gt;
                  &lt;MockObject Name="Leslie" Type="F" Number="8" /&gt;
                  &lt;MockObject Name="Mike" Type="G" Number="9" /&gt;
                  &lt;MockObject Name="Sue" Type="H" Number="10" /&gt;
                  &lt;MockObject  Name="Michelle" Type="I" Number="11" /&gt;
                  &lt;MockObject Name="Ron" Type="J" Number="12" /&gt;
                  &lt;MockObject Name="Amy" Type="K" Number="13" /&gt;
              &lt;/MockObjects&gt;
          &lt;/x:XData&gt;
      &lt;/XmlDataProvider&gt;
  &lt;/Window.Resources&gt;
  
  &lt;DockPanel&gt;
      &lt;Menu Grid.Row="0" BorderThickness="0,0,0,1"&gt;
          &lt;MenuItem Header="_File"&gt;
              &lt;MenuItem Header="Custom Presets" DataContext="{Binding Source={StaticResource MockList}}"  ItemsSource="{Binding Mode=Default, XPath=/MockObjects/MockObject}"&gt;
                  &lt;MenuItem.ItemContainerStyle&gt;
                      &lt;Style&gt;
                          &lt;Setter Property="MenuItem.Header" Value="{Binding XPath=@Name}"/&gt;
                          &lt;Setter Property="MenuItem.Command" Value="{Binding Open}"/&gt;
                      &lt;/Style&gt;
                  &lt;/MenuItem.ItemContainerStyle&gt;
                  &lt;!--&lt;MenuItem.ItemTemplate&gt;
                      &lt;HierarchicalDataTemplate&gt;
                          &lt;StackPanel Orientation="Horizontal"&gt;
                              &lt;TextBlock Text="{Binding Header}"/&gt;
                              &lt;TextBlock Text="{Binding XPath=@Name}" Width="150" Foreground="Red"/&gt;
                              &lt;Button Content="X" Background="Firebrick" Cursor="Hand"/&gt;
                          &lt;/StackPanel&gt;
                      &lt;/HierarchicalDataTemplate&gt;
                  &lt;/MenuItem.ItemTemplate&gt;--&gt;
              &lt;/MenuItem&gt;
  
          &lt;/MenuItem&gt;
      &lt;/Menu&gt;
  &lt;/DockPanel&gt;    
  </code></pre>
  
  <p></p>