title: ContentControl two way binding within DataTemplate not working?
body: <p>I've setup a reusable datatemplate "DataGridCheckBoxEdit" for a datagrid column. Binding to it one way works like a charm through ContentControl. Binding directly works two way correctly. However, binding two way within that DataTemplate, from a ContentControl just won't work.</p>
  
  <p>Here are the snippets:</p>
  
  <pre><code>&lt;DataGridTemplateColumn.CellEditingTemplate&gt;
  &lt;DataTemplate&gt;
  &lt;ContentControl Content="{Binding Path=IsMadeAvailable, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ContentTemplate="{StaticResource     DataGridCheckBoxEdit}" /&gt;
  &lt;/DataTemplate&gt;
  &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
  </code></pre>
  
  <p>and the reusable template:</p>
  
  <pre><code>&lt;DataTemplate x:Key="DataGridCheckBoxEdit"&gt;
  &lt;CheckBox Name="CheckBoxControl" IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContentControl}, Path=DataContext.Content, Mode=TwoWay, BindsDirectlyToSource=True, UpdateSourceTrigger=PropertyChanged}" Margin="8,4,2,2" /&gt;
  &lt;DataTemplate.Triggers&gt;
  &lt;Trigger SourceName="CheckBoxControl" Property="IsVisible" Value="True"&gt;
  &lt;Setter TargetName="CheckBoxControl" Property="FocusManager.FocusedElement" Value="{Binding ElementName=CheckBoxControl}"/&gt;
  &lt;/Trigger&gt;
  &lt;/DataTemplate.Triggers&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>As I said, one way binding works like a charm...but getting the data back to the property doesn't.</p>
  
  <p>Of course, putting it without being reusable:</p>
  
  <pre><code>&lt;DataGridTemplateColumn.CellEditingTemplate&gt;
  &lt;DataTemplate&gt;
  &lt;CheckBox Name="GasIsAvailableCheckBox" IsChecked="{Binding Path=IsMadeAvailable, UpdateSourceTrigger=PropertyChanged}" Margin="8,4,2,2" /&gt;
  &lt;DataTemplate.Triggers&gt;
  &lt;Trigger SourceName="GasIsAvailableCheckBox" Property="IsVisible" Value="True"&gt;
  &lt;Setter TargetName="GasIsAvailableCheckBox" Property="FocusManager.FocusedElement" Value="{Binding ElementName=GasIsAvailableCheckBox}"/&gt;
  &lt;/Trigger&gt;
  &lt;/DataTemplate.Triggers&gt;
  &lt;/DataTemplate&gt;
  &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
  </code></pre>
  
  <p>also works great, and works two-way.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks!</p>
  
  <p>Vladan</p>