title: How can I change the Style of a WPF TabControl's ItemTemplate so that I can set the Tab Headers' Background color?
body: <p>I am using the WPF TabControl's ItemTemplate property to bind the content of each TabItem's header. I am also using the ItemContainerStyle property to set the TabItem's content to a dynamically selected user control.  This method is working 100% as expected, but I am having trouble now with styling the TabControl's header.</p>
  
  <p>I set the background property of the TabControl to black:</p>
  
  <pre><code>&lt;TabControl
          ItemsSource="{Binding Tabs.Tabs}"
          SelectedItem="{Binding Tabs.SelectedTab, Mode=TwoWay}"
          IsEnabled="{Binding ReadyForInput}"
          Background="Black"
          x:Name="MainTab"&gt;
          &lt;TabControl.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;StackPanel
                      Orientation="Horizontal"&gt;                      
                      &lt;TextBlock
                          Text="{Binding TabHeader}"
                          VerticalAlignment="Center"
                          HorizontalAlignment="Center" /&gt;
                  &lt;/StackPanel&gt;
              &lt;/DataTemplate&gt;
          &lt;/TabControl.ItemTemplate&gt;
          &lt;TabControl.ItemContainerStyle&gt;
              &lt;Style
                  TargetType="TabItem"&gt;
                  &lt;Setter
                      Property="Content"
                      Value="{Binding TabContentControl}" /&gt;
              &lt;/Style&gt;
          &lt;/TabControl.ItemContainerStyle&gt;
      &lt;/TabControl&gt;
  </code></pre>
  
  <p>This results in:
  <a href="https://i.stack.imgur.com/pXNIA.png" rel="nofollow noreferrer">The TabItem has a black background, but the header stays the same.</a></p>
  
  <p>If I set the background color of the StackPanel in the ItemTemplate, I'm left with <a href="https://i.stack.imgur.com/J1kGl.png" rel="nofollow noreferrer">this.</a></p>
  
  <p>How can I change the background color (style) of the TabItems' header when the TabControl is bound as I have it?</p>
  
  <p>Thank you!</p>