title: How do I bind the visibility of a CheckBox in a DataGrid to the DataContext of that row?
body: <p>I have a JibGrid DataGrid like so (JibGrid is an open-source relatively simple subclass of a standard DataGrid to implement stuff like filtering etc):</p>
  
  <pre><code>&lt;dataGrid:JibGrid ItemsSource="{Binding AvailableRDs}" 
                              FilteredItemsSource="{Binding AvailableRDs}"
                              SelectedItem="{Binding SelectedAvailRD}" 
                              AutoGenerateColumns="False" &gt;
      &lt;dataGrid:JibGrid.Columns&gt;
          &lt;DataGridCheckBoxColumn Header="Add?" Binding="{Binding Add}" Visibility="{Binding GetAddVisibility}"/&gt;
          &lt;DataGridTextColumn Header="Tag" Binding="{Binding Tag}" /&gt;
          &lt;DataGridTextColumn Header="Revision Tag" Binding="{Binding RevisionTag}" /&gt;
          &lt;DataGridTextColumn Header="Current System" Binding="{Binding SystemStr}" /&gt;
      &lt;/dataGrid:JibGrid.Columns&gt;
  &lt;/dataGrid:JibGrid&gt;
  </code></pre>
  
  <p>The intent is that there is a custom class for each row that provides properties for the content of each cell in that row - Tag, RevisionTag, etc. All of that works fine. What I can't get to work is that Visibility binding. I would like for the checkbox in each row to be invisible if the CanAdd property on the class representing that Row in the DataContext returns False. When I add the Visibility binding in XAML as above, it seems that what happens is that WPF attempts to apply this binding to the actual column instead of for each row, so the binding fails to connect. I can go in using WPF explorer and manually bind a row's checkbox visibility DependencyProperty to the CanAdd property of the Row's datacontext, and that works fine, but I can't figure out how to, in XAML or code, cause it to generate that binding for the checkbox in every row automatically. Anybody have any ideas on that?</p>
  
  <p>I have searched around for questions like this, and it seems that, for some reason, everybody wants to change the visibility of the column itself based on something in the datacontext of the whole grid, and nobody else wants to change the visibility of things in individual rows based on that row's datacontext. I tried the solution <a href="https://stackoverflow.com/questions/7660967/wpf-error-cannot-find-govering-frameworkelement-for-target-element">here</a> while I was trying to figure this out, and that's what that answer is trying to do.</p>