Is It Possible To Customize TabControl Tabs Style In WPF?

xaml
wpf

(It Soft) #1

I am wondering, how can I customize the TabControl Tabs Style in WPF using XAML.
Is there any easy way of doing it?


(jms) #2

I believe I answered similar question a while ago.

What you need to do is, re-style your TabItem Control. That’s the Control WPF uses to represent Tabs within any given TabControl.

An simple TabItem Style should look something like this:

<Style x:Key="MyNewTabItemStyle" TargetType="{x:Type TabItem}">
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type TabItem}">
                <Border x:Name="PART_Border" Background="{TemplateBinding Background}" BorderThickness="1" BorderBrush="LightGray" Margin="2">
                    <ContentPresenter ContentSource="Header" Margin="2" />
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsSelected" Value="True">
                        <Setter TargetName="PART_Border" Property="BorderBrush" Value="Black" />
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

P.S. You can also make it a bit “fancy” by adding Animated Triggers, Colors…etc. But the XAML code snippet above should get you on track.

For a more detailed answer please check this thread: