Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to change background color of TabControl.Header
    text
    copied!<p>I need to change the background color of the TabControl header, but TabControl haven't property for it, how can I do it. Help me please. Here is my code:</p> <pre><code>&lt;Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="502" Width="628"&gt; &lt;TabControl Background="#123" TabStripPlacement="Left" HorizontalAlignment="Stretch" BorderBrush="#41020202"&gt; &lt;TabControl.BitmapEffect&gt; &lt;DropShadowBitmapEffect Color="Black" Direction="270"/&gt; &lt;/TabControl.BitmapEffect&gt; &lt;TabControl.Resources&gt; &lt;Style TargetType="{x:Type TabItem}"&gt; &lt;Setter Property="BorderThickness" Value="0"/&gt; &lt;Setter Property="Padding" Value="0" /&gt; &lt;Setter Property="HeaderTemplate"&gt; &lt;Setter.Value&gt; &lt;DataTemplate&gt; &lt;Border x:Name="grid" Background="Red"&gt; &lt;ContentPresenter&gt; &lt;ContentPresenter.Content&gt; &lt;TextBlock Margin="4" FontSize="15" Text="{TemplateBinding Content}"/&gt; &lt;/ContentPresenter.Content&gt; &lt;ContentPresenter.LayoutTransform&gt; &lt;RotateTransform Angle="270" /&gt; &lt;/ContentPresenter.LayoutTransform&gt; &lt;/ContentPresenter&gt; &lt;/Border&gt; &lt;DataTemplate.Triggers&gt; &lt;DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type TabItem}},Path=IsSelected}" Value="True"&gt; &lt;Setter TargetName="grid" Property="Background" Value="Green"/&gt; &lt;/DataTrigger&gt; &lt;/DataTemplate.Triggers&gt; &lt;/DataTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/TabControl.Resources&gt; &lt;TabItem Header="Tab Item 1" /&gt; &lt;TabItem Header="Tab Item 2" /&gt; &lt;TabItem Header="Tab Item 3" /&gt; &lt;TabItem Header="Tab Item 4" /&gt; &lt;/TabControl&gt; &lt;/Window&gt; </code></pre> <p>Here is my result: <img src="https://i.stack.imgur.com/j5w8N.png" alt="My result"></p> <p>Here is result that I need: <img src="https://i.stack.imgur.com/5Y0ia.png" alt="Here is result that I need"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload