title: WPF: regarding the binding inside of DataGridTextColumns
body: <p>Today I noticed a strange behavior regarding binding the header of a DataGridColumn to the ViewModel.</p>
  
  <p>The following binding works perfectly (name of the DataGrid is MyGrid):</p>
  
  <pre><code>&lt;DataGridTextColumn Binding="{Binding Name}"  Width="*" CanUserReorder="False" CanUserResize="False" IsReadOnly="True"&gt;
                                  &lt;DataGridTextColumn.HeaderTemplate&gt;
                                      &lt;DataTemplate&gt;
                                          &lt;TextBlock Text="{Binding ElementName=MyGrid, Path=DataContext.MyDeviceViewModel.CategoryHeader}"/&gt;
                                      &lt;/DataTemplate&gt;
                                  &lt;/DataGridTextColumn.HeaderTemplate&gt;
   &lt;/DataGridTextColumn&gt;
  </code></pre>
  
  <p>Whereas the following does not work (it complains that MyGrid cannot be found):</p>
  
  <pre><code>&lt;DataGridTextColumn Binding="{Binding Name}"  Width="*" CanUserReorder="False" CanUserResize="False" IsReadOnly="True"&gt;
      &lt;DataGridTextColumn.Header&gt;
          &lt;TextBlock Text="{Binding ElementName=MyGrid, Path=DataContext.MyDeviceViewModel.CategoryHeader}"/&gt;
      &lt;/DataGridTextColumn.Header&gt;
  &lt;/DataGridTextColumn&gt;
  </code></pre>
  
  <p>What is the difference between binding to the viewmodel in the Template or in the UIElement directly?</p>