title: WPF XAML defined MenuItem reuse starts working, then disappears
body: <p>The following simple code attempts to reuse a MenuItem defined in the Window.Resources on two separate Menus. </p>
  
  <pre><code>&lt;Window x:Class="WpfApplication.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:collections="clr-namespace:System.Collections;assembly=mscorlib"
          Title="MainWindow" Height="350" Width="525"&gt;
    &lt;Window.Resources&gt;
      &lt;collections:ArrayList x:Key="menuItemValues"&gt;
         &lt;MenuItem Header="First"/&gt;
         &lt;MenuItem Header="Second"/&gt;
         &lt;MenuItem Header="Third"/&gt;
      &lt;/collections:ArrayList&gt;
      &lt;MenuItem x:Key="menuItem" x:Shared="False"
                ItemsSource="{StaticResource menuItemValues}"
                Header="Shared menu item"/&gt;
    &lt;/Window.Resources&gt;
    &lt;StackPanel&gt;
      &lt;Menu HorizontalAlignment="Left" VerticalAlignment="Top"&gt;
        &lt;StaticResource ResourceKey="menuItem"/&gt;
        &lt;StaticResource ResourceKey="menuItem"/&gt;
      &lt;/Menu&gt;
    &lt;/StackPanel&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>This starts out great and when you first select the menus, all looks well.  The first menu has the desired MenuItems, </p>
  
  <p><a href="https://i.stack.imgur.com/dxZvc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dxZvc.png" alt="enter image description here"></a></p>
  
  <p>So does the second:</p>
  
  <p><a href="https://i.stack.imgur.com/GMrLk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GMrLk.png" alt="enter image description here"></a></p>
  
  <p>But when you navigate back to the first menu, the MenuItems disappear:</p>
  
  <p><a href="https://i.stack.imgur.com/ZURAa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZURAa.png" alt="enter image description here"></a></p>
  
  <p>Can someone explain why the menu disappears and a way to get this to work?</p>
  
  <p>This was discovered while investigating another <a href="https://stackoverflow.com/questions/35808867/why-does-an-xarray-element-cause-any-xshared-attribute-following-it-to-be-igno">SO question</a> that was getting an exception.  I tried to use a strategy discussed on <a href="https://stackoverflow.com/questions/13630645/how-do-i-reuse-item-children-via-a-style-in-xaml">another SO question</a> and it seemed to solve the problem until you navigate back to the menu a second time and it disappears.</p>
  
  <p>I have reproduced this issue on 2 separate machines:  </p>
  
  <ol>
  <li>Win 10, VS2013 Ult V12.0.40629.00 Update 5, .NET V4.6.0138</li>
  <li>Win 7, VS2013 Prem V12.0.31101.00 Update 4, .NET V4.5.51209</li>
  </ol>