title: Binding ContextMenu to Datagrid Columns
body: <p>I am trying to bind <code>DataGrid</code> column header to its own <code>ContextMenu</code> like this:</p>
  
  <pre><code> &lt;DataGrid x:Name="AllLogs"&gt;
       &lt;DataGrid.ContextMenu&gt;
           &lt;ContextMenu&gt;
                &lt;MenuItem Header="Show/Hide Columns" 
                          ItemsSource="{Binding ElementName=AllLogs, Path=Columns}"&gt;
                      &lt;MenuItem.ItemTemplate&gt;
                           &lt;DataTemplate&gt;
                               &lt;TextBlock Text="{Binding Header}"&gt;&lt;/TextBlock&gt;
                           &lt;/DataTemplate&gt;
                      &lt;/MenuItem.ItemTemplate&gt;
                &lt;/MenuItem&gt;
             &lt;/ContextMenu&gt;
         &lt;/DataGrid.ContextMenu&gt;
     &lt;/DataGrid&gt;
  </code></pre>
  
  <p>Its always sends the following error in output:</p>
  
  <blockquote>
    <p>Cannot find source for binding with reference
    'ElementName=AllLogs'. BindingExpression:Path=Columns;
    DataItem=null; target element is 'MenuItem' (Name=''); target property
    is 'ItemsSource' (type 'IEnumerable')</p>
  </blockquote>
  
  <hr>
  
  <p><strong>EDIT: Binding with a <code>ComboBox</code> works as expected</strong></p>
  
  <pre><code> &lt;ComboBox ItemsSource="{Binding ElementName=AllLogs, Path=Columns}"&gt;
          &lt;ComboBox.ItemTemplate&gt;
                &lt;DataTemplate&gt;
                    &lt;CheckBox Content="{Binding Header}"/&gt;
                &lt;/DataTemplate&gt;
           &lt;/ComboBox.ItemTemplate&gt;
   &lt;/ComboBox&gt;
  </code></pre>