title: WPF styling tabitem text foreground upon trigger such as IsEnabled, IsMouseOver, etc
body: <p>I'm trying to change the foreground text colour of a WPF tab item's header textblock using triggers. This works fine for most (simpler) scenarios but not when TextBlocks have been globally styled.</p>
  
  <p>So this simple "mouse over" trigger would work in terms of changing the foreground color:</p>
  
  <pre><code>&lt;Style x:Key="testTabItemStyle1" TargetType="{x:Type TabItem}"&gt;
  &lt;Setter Property="Foreground" Value="Black"/&gt;
  &lt;Setter Property="Background" Value="White"/&gt;
  &lt;Setter Property="HorizontalContentAlignment" Value="Stretch"/&gt;
  &lt;Setter Property="VerticalContentAlignment" Value="Stretch"/&gt;
  &lt;Setter Property="Template"&gt;
     &lt;Setter.Value&gt;
       &lt;ControlTemplate TargetType="{x:Type TabItem}"&gt;
         &lt;Grid SnapsToDevicePixels="true"&gt;
           &lt;Border x:Name="Bd" Background="White" BorderBrush="Gray" BorderThickness="1,1,1,0"&gt;
              &lt;ContentPresenter HorizontalAlignment="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" x:Name="Content" VerticalAlignment="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" ContentSource="Header"/&gt;
           &lt;/Border&gt;
         &lt;/Grid&gt;
         &lt;ControlTemplate.Triggers&gt;
           &lt;Trigger Property="IsMouseOver" Value="true"&gt;
             &lt;Setter Property="Background" TargetName="Bd" Value="Black"/&gt;
             &lt;Setter Property="Foreground" Value="False"/&gt;
           &lt;/Trigger&gt;
         &lt;/ControlTemplate.Triggers&gt;
       &lt;/ControlTemplate&gt;
     &lt;/Setter.Value&gt;
  &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>The problem is that when TextBlocks are globally styled in App.xaml (for maintaining a consistent look), the foreground does not change, but retains the globally styled foreground color. This is how my TextBlocks are styled:</p>
  
  <pre><code>    &lt;Style TargetType="{x:Type TextBlock}"&gt;
          &lt;Setter Property="FontFamily" Value="Arial"/&gt;
          &lt;Setter Property="Foreground" Value="Brown"/&gt;
          &lt;Setter Property="Margin" Value="4,0,4,0"/&gt;
          &lt;Setter Property="TextTrimming" Value="CharacterEllipsis"/&gt;
          &lt;Setter Property="TextWrapping" Value="NoWrap"/&gt;
          &lt;Setter Property="VerticalAlignment" Value="Center"/&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p>So my question is shouldn't the explicitly defined style assignment (in TabItem's trigger) have precedence? More importantly, how do I work around this without assigning styles to all my textblocks individually but having the TabItem textblock change color as expected?</p>
  
  <p>Many thanks</p>
  
  <p>NT</p>