Reputation: 16979
Made a great looking tab in Blend, but my ContentPresenter
must be off - its not displaying the TabItem
Header text.
Edit 1: Implemented CodeNaked's suggestion, and Rachel's answer so you can just use this style as is if you like.
<Style x:Key="TabItemStyle2" TargetType="{x:Type TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid>
<Border BorderThickness="3" CornerRadius="5,5,0,0">
<Border.BorderBrush>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#7F605F5F" Offset="0"/>
<GradientStop Color="#7F7E7E7E" Offset="1"/>
</LinearGradientBrush>
</Border.BorderBrush>
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF6096E5" Offset="0.004"/>
<GradientStop Color="#FF6096E5" Offset="0.823"/>
<GradientStop Color="White" Offset="0.228"/>
</LinearGradientBrush>
</Border.Background>
</Border>
<Border x:Name="BorderGlass" BorderThickness="3" CornerRadius="5,5,0,0" Background="#7FFDFDFD">
<Border.BorderBrush>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#7FFFFFFF" Offset="0"/>
<GradientStop Color="#BFFFFFFF" Offset="0.401"/>
<GradientStop Color="#F2FFFFFF" Offset="0.254"/>
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
<ContentPresenter HorizontalAlignment="Center" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center" ContentPresenter ContentSource="Header">
<ContentPresenter.OpacityMask>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF6096E5" Offset="0"/>
<GradientStop Color="#FF6096E5" Offset="0.823"/>
<GradientStop Color="White" Offset="0.228"/>
</LinearGradientBrush>
</ContentPresenter.OpacityMask>
</ContentPresenter>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Upvotes: 0
Views: 292
Reputation: 41403
Your first Style isn't really valid. You should not define the control in the control you are Styling. In your first Style, you include a TabItem in the control template for a TabItem. Which you shouldn't do.
Rachel's answer addresses issues with your second Style.
Upvotes: 1
Reputation: 132618
Try adding ContentSource="Header"
to your ContentPresenter
<ContentPresenter ContentSource="Header" ... >
Upvotes: 2