title: Can I apply a WPF style to an element only in a certain layout?
body: <p>I have a <code>TextBlock</code> style like this:</p>
  
  <pre><code>&lt;Style TargetType="TextBlock" x:Key="FormLabel"&gt;
      &lt;Setter Property="Height" Value="20" /&gt;
      &lt;Setter Property="Margin" Value="10" /&gt;
      &lt;Setter Property="TextAlignment" Value="Right" /&gt;
      &lt;Setter Property="VerticalAlignment" Value="Center" /&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>I use it in <code>Grid</code> based forms, e.g:</p>
  
  <pre><code>&lt;TextBlock Text="Code" Grid.Row="1" Grid.Column="0" Style="{StaticResource FormLabel}" /&gt;
  </code></pre>
  
  <p>Now instead of repeating the style name on every <code>TextBlock</code> in the grid, I would prefer to e.g. have a <code>Grid</code> style like:</p>
  
  <pre><code>&lt;Style TargetType="Grid" x:Key="FormGrid"&gt;
      &lt;Setter Property="Width" Value="400" /&gt;
      ...
  &lt;/Style&gt;
  </code></pre>
  
  <p>Then I would, if possible, like to modify my <code>TextBlock</code> style to only apply to that element when it is a child element of a <code>Grid</code> with style <code>FormGrid</code>. </p>
  
  <p>Is this possible, and if so, how can I achieve it?</p>