Click here to Skip to main content
15,792,510 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to implement style for TabControl along with TabItem like below Images:

The Style should make below things visible:
1. White Background for TabControl and selected TabItem with Dropshadow Effect.
2. When any TabItem is not selected, then the TabItem text color should turn to gray.

If anyone can help me achieving TabControl with such style would be a great help.
Thanks in advance.

What I have tried:

What I have achieved till now:
1. Able to devide width of TabControl to accomodate TabItem items with equal Sizes using TabSizeConverter converter.
2. Able to change background and with of TabControl and TabItems. But not able to achieve Dropshadow effect.
3. Below is my Style for TabItem:

<local:TabSizeConverter x:Key="tabSizeConverter" />
<Style x:Key="style_TabControlItemTab" TargetType="{x:Type TabItem}">
	<Setter Property="Padding" Value="0"></Setter>
	<Setter Property="IsTabStop" Value="False"></Setter>
	<Setter Property="Foreground" Value="{StaticResource color_MediumGray}"/>
	<Setter Property="FontSize" Value="34"/>
	<Setter Property="FontFamily" Value="Resources/Fonts/#HelveticaNeueMed" />
	<Setter Property="Width">
			<MultiBinding Converter="{StaticResource tabSizeConverter}">
				<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type TabControl}}" />
				<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type TabControl}}" Path="ActualWidth" />
	<Setter Property="Template">
			<ControlTemplate TargetType="{x:Type TabItem}">
				<Border x:Name="Chrome"
					BorderBrush="{StaticResource color_Transparent}" 
					Background="{StaticResource color_LightGray}" 
					Padding="0" Margin="0">
					<ContentPresenter ContentSource="Header" 
					HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
					VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
					<Trigger Property="Selector.IsSelected" Value="True">
						<Setter TargetName="Chrome" Property="BorderThickness" Value="0"/>
						<Setter TargetName="Chrome" Property="Background" Value="{StaticResource color_White}"/>
						<Setter Property="Foreground" Value="{StaticResource color_Purple}"/>
Updated 3-Apr-17 3:53am

1 solution

There are many tutorials and solutions that can be found on Google Search for Drop Shadow: wpf xaml dropshadow[^]

Also official documentation: How to: Create a Drop Shadow Visual Effect[^]

I think that this is the answer that you are looking for: xaml - WPF TabItem and TabControl templates combined - Stack Overflow[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900