title: RelativeSource data trigger binding not working
body: <p>I am trying to set the background color of a <code>DataGridTextColumn</code> to another color if it is read-only. I am doing so with the following code:</p>
  
  <pre><code>&lt;DataGridTextColumn Header="Test" IsReadOnly="True"&gt;
      &lt;DataGridTextColumn.ElementStyle&gt;
          &lt;Style TargetType="{x:Type TextBlock}"&gt;
              &lt;Style.Triggers&gt;
                  &lt;DataTrigger Binding="{Binding IsReadOnly, RelativeSource={RelativeSource Mode=FindAncestor,  AncestorType={x:Type DataGridTextColumn}}}" Value="True"&gt;
                      &lt;Setter Property="Background" Value="LightGreen"/&gt;
                  &lt;/DataTrigger&gt;
              &lt;/Style.Triggers&gt;
          &lt;/Style&gt;
      &lt;/DataGridTextColumn.ElementStyle&gt;
  &lt;/DataGridTextColumn&gt;
  </code></pre>
  
  <p>I am having no luck, however removing the triggers results in the background always being light green. Is something wrong with the data trigger binding? I am relatively new to WPF but this is what I could find online. Ideally this would be in App.XAML so it would work across all columns such as this, so would there then be a way to translate this to a style? Thanks.</p>
  
  <p>Edit---------</p>
  
  <p>If I bind by ElementName it works:</p>
  
  <pre><code>&lt;DataTrigger Binding="{Binding IsReadOnly, ElementName=stupid}" Value="True"&gt;
          &lt;Setter Property="Foreground" Value="Red" /&gt;
  &lt;/DataTrigger&gt;
  </code></pre>
  
  <p>However I would like this to be more generic if possible. Thanks again.</p>