TabItem Header Name

Nov 25, 2012 at 11:08 AM
Edited Nov 25, 2012 at 2:05 PM
I'm try this example TabControl Navigation if using style for TabControl not set TabItem header name, What is the solution?

http://stackoverflow.com/questions/13214705/caliburn-micro-and-tabcontrol

 

            <Style x:Key="TabItemHeaderStyle" TargetType="{x:Type ContentControl}">
                <Setter Property="Background" Value="Black"/>
                <Setter Property="BorderBrush" Value="Chocolate"/>
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="Foreground" Value="CadetBlue"/>
                <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.HeaderFontSize), Mode=OneWay}"/>
                <Setter Property="FontStretch" Value="Medium"/>
                <Setter Property="FontStyle" Value="Normal"/>
                <Setter Property="FontWeight" Value="Normal"/>
                <Setter Property="TextOptions.TextFormattingMode" Value="Display"/>
                <Setter Property="TextOptions.TextRenderingMode" Value="ClearType"/>
                <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled"/>
                
                <Setter Property="Focusable" Value="True"/>
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"/>
                <Setter Property="SnapsToDevicePixels" Value="True"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ContentControl}">
                            <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                                <Grid TextBlock.Foreground="{TemplateBinding Foreground}"
                              TextBlock.FontFamily="{TemplateBinding FontFamily}"
                              TextBlock.FontSize="{TemplateBinding FontSize}"
                              TextBlock.FontStretch="{TemplateBinding FontStretch}"
                              TextBlock.FontStyle="{TemplateBinding FontStyle}"
                              TextBlock.FontWeight="{TemplateBinding FontWeight}"
                              TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}"
                              TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}"
                              RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}"
                              HorizontalAlignment="Stretch"
                              VerticalAlignment="Stretch">
                                    <Rectangle x:Name="Indicator"
                                       Fill="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=(params:TabControl.IndicatorBrush)}"
                                       StrokeThickness="0"
                                       Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=(params:TabControl.IndicatorThickness)}"
                                       HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
                                    <ContentPresenter Margin="{TemplateBinding Padding}" 
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                      
                                              RecognizesAccessKey="True"/>
                                </Grid>
                            </Border>
                            <ControlTemplate.Triggers>
                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=TabStripPlacement}" Value="{x:Static Dock.Bottom}">
                                    <Setter TargetName="Indicator" Property="VerticalAlignment" Value="Top"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=TabStripPlacement}" Value="{x:Static Dock.Left}">
                                    <Setter Property="LayoutTransform">
                                        <Setter.Value>
                                            <RotateTransform Angle="-90"/>
                                        </Setter.Value>
                                    </Setter>
                                    <Setter TargetName="Indicator" Property="VerticalAlignment" Value="Bottom"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=TabStripPlacement}" Value="{x:Static Dock.Right}">
                                    <Setter Property="LayoutTransform">
                                        <Setter.Value>
                                            <RotateTransform Angle="90"/>
                                        </Setter.Value>
                                    </Setter>
                                    <Setter TargetName="Indicator" Property="VerticalAlignment" Value="Bottom"/>
                                </DataTrigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=TabStripPlacement}" Value="{x:Static Dock.Left}">
                        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=TabStripPlacement}" Value="{x:Static Dock.Right}">
                        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal"/>
                    </DataTrigger>
              
 
                </Style.Triggers>
            </Style>

            <Style x:Key="ItemStyle" TargetType="{x:Type TabItem}">
                <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=Background, Mode=OneWay}"/>
                <Setter Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=BorderBrush, Mode=OneWay}"/>
                <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=BorderThickness, Mode=OneWay}"/>
                <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=Foreground, Mode=OneWay}"/>
                <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=FontSize, Mode=OneWay}"/>
                <Setter Property="FontStretch" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=FontStretch, Mode=OneWay}"/>
                <Setter Property="FontStyle" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=FontStyle, Mode=OneWay}"/>
                <Setter Property="FontWeight" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=FontWeight, Mode=OneWay}"/>
                <Setter Property="TextOptions.TextFormattingMode" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=(TextOptions.TextFormattingMode), Mode=OneWay}"/>
                <Setter Property="TextOptions.TextRenderingMode" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=(TextOptions.TextRenderingMode), Mode=OneWay}"/>
                <Setter Property="RenderOptions.ClearTypeHint" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=(RenderOptions.ClearTypeHint), Mode=OneWay}"/>
             
                <Setter Property="Focusable" Value="True"/>
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=Padding, Mode=OneWay}"/>
                <Setter Property="params:TabItem.HeaderStyle" Value="{StaticResource TabItemHeaderStyle}"/>
                <Setter Property="params:TabControl.IndicatorBrush" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=(params:TabControl.IndicatorBrush)}"/>
                <Setter Property="OverridesDefaultStyle" Value="True"/>
                <Setter Property="SnapsToDevicePixels" Value="True"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TabItem}">
                            <ContentControl x:Name="ContentHost"
                                    Content="{TemplateBinding Header}"
                                    TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}"
                                    TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}"
                                    RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}"
                                    Style="{TemplateBinding params:TabItem.HeaderStyle}"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
         
            </Style>

Thanks.