title: Hide DataTrigger if RelativeSource doesn't exist
body: <p>I want to add a DataTrigger to my base TextBox style so that it sets the foreground color to a different value if it is inside of a DataGridCell that is selected. Here is what my trigger looks like:</p>
  
  <pre><code>&lt;Style.Triggers&gt;
      &lt;DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type DataGridCell}}, Path=IsSelected}"
                   Value="True"&gt;
          &lt;Setter Property="Foreground"
                  Value="White" /&gt;
      &lt;/DataTrigger&gt;
  &lt;/Style.Triggers&gt;
  </code></pre>
  
  <p>This works great, except that when my TextBox is not in a DataGrid the Binding fails and writes an exception to the output window. How can I prevent this. </p>
  
  <p>I basically want to say if Parent is a DataGridCell then apply this trigger otherwise ignore it.</p>