title: ElementName Binding from MenuItem in ContextMenu
body: <p>Has anybody else noticed that Bindings with ElementName do not resolve correctly for <code>MenuItem</code> objects that are contained within <code>ContextMenu</code> objects? Check out this sample:</p>
  
  <pre><code>&lt;Window x:Class="EmptyWPF.Window1"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="Window1" Height="300" Width="300"
      x:Name="window"&gt;
      &lt;Grid x:Name="grid" Background="Wheat"&gt;
          &lt;Grid.ContextMenu&gt;
              &lt;ContextMenu x:Name="menu"&gt;
                  &lt;MenuItem x:Name="menuItem" Header="Window" Tag="{Binding ElementName=window}" Click="MenuItem_Click"/&gt;
                  &lt;MenuItem Header="Grid" Tag="{Binding ElementName=grid}" Click="MenuItem_Click"/&gt;
                  &lt;MenuItem Header="Menu" Tag="{Binding ElementName=menu}" Click="MenuItem_Click"/&gt;
                  &lt;MenuItem Header="Menu Item" Tag="{Binding ElementName=menuItem}" Click="MenuItem_Click"/&gt;
              &lt;/ContextMenu&gt;
          &lt;/Grid.ContextMenu&gt;
          &lt;Button Content="Menu" 
                  HorizontalAlignment="Center" VerticalAlignment="Center" 
                  Click="MenuItem_Click" Tag="{Binding ElementName=menu}"/&gt;
          &lt;Menu HorizontalAlignment="Center" VerticalAlignment="Bottom"&gt;
              &lt;MenuItem x:Name="anotherMenuItem" Header="Window" Tag="{Binding ElementName=window}" Click="MenuItem_Click"/&gt;
              &lt;MenuItem Header="Grid" Tag="{Binding ElementName=grid}" Click="MenuItem_Click"/&gt;
              &lt;MenuItem Header="Menu" Tag="{Binding ElementName=menu}" Click="MenuItem_Click"/&gt;
              &lt;MenuItem Header="Menu Item" Tag="{Binding ElementName=anotherMenuItem}" Click="MenuItem_Click"/&gt;
          &lt;/Menu&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>All of the bindings work great except for the bindings contained within the ContextMenu. They print an error to the Output window during runtime.</p>
  
  <p>Any one know of any work arounds? What's going on here?</p>