title: WPF Binding to ElementName inside ItemsControl
body: <p>I have a checkbox, and an ItemsControl populating several DataGrids the following way:</p>
  
  <pre><code>&lt;Checkbox Content="Birthday Column Visible" x:Name="UI_BirthdayVisibleCB" /&gt;
  
  &lt;ItemsControl  ItemsSource="{Binding Path=ParentsCollection}"&gt;
     &lt;ItemsControl.ItemTemplate&gt;
        &lt;DataTemplate&gt;
           &lt;DataGrid  AutoGenerateColumns="False" ItemsSource="{Binding Children}"&gt;
              &lt;DataGrid.Columns&gt;
                  &lt;DataGridTemplateColumn Header="Birthday" Width="120" Visibility="{Binding IsChecked, ElementName=UI_BirthdayVisibleCB, Converter={StaticResource BoolToVis}}" &gt;
  ...
                 &lt;/DataGridTemplateColumn&gt;
              &lt;/DataGrid.Columns&gt;
           &lt;/DataGrid&gt;
  &lt;/Rest of closing tags&gt;
  </code></pre>
  
  <p>This creates binding output errors as it tries to find IsChecked on the DataGridTemplateColumn. If I try to search for a Relative Ancestor I receive the exception:</p>
  
  <pre><code>Binding.RelativeSource cannot be set while using Binding.ElementName.
  </code></pre>
  
  <p>I have a ViewModel, and stick to MVVM mostly, but in this case I'd really like to keep the column visibilities on the View layer. Note that <code>BoolToVis</code> just converts Boolean to Visibility.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Here is an example of what I'm trying to do:  </p>
  
  <pre><code> &lt;DataGridTemplateColumn Header="Birthday" Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MyView} }, Path=IsChecked, ElementName=UI_BirthdayVisibleCB, Converter={StaticResource BoolToVis}}" /&gt;
  </code></pre>
  
  <p>It compiles but doesn't run however, it throws the exception above.</p>