且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何改变所选标签的样式

更新时间:2023-01-27 19:17:27

您好



尝试完全更改模板:

http://msdn.microsoft.com/en- us / library / ms754137%28v = vs.110%29.aspx [ ^ ]



问候

Joseph Leung

I am Using following code to change the style for the selected tab

<pre lang="xml"><Style TargetType="{x:Type TabItem}" x:Key="TabItemStyle">
    <Style.Triggers>
        <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=TabItem}}" Value="True">
            <Setter Property="Background" >
                <Setter.Value>
                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                        <GradientStop Color="LightBlue" Offset="0" />
                        <GradientStop Color="BlanchedAlmond" Offset="1" />
                        <GradientStop Color="#A50000C9" Offset="0.376" />
                        <GradientStop Offset="0.848" />
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="FontSize" Value="18" />
        </DataTrigger>
        <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=TabItem}}" Value="False">
            <Setter Property="Background" >
                <Setter.Value>
                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                        <GradientStop Color="LightGray"  Offset="0" />
                        <GradientStop Color="DarkOrange"  Offset="1" />
                        <GradientStop Color="#A50000C9" Offset="0.376" />
                        <GradientStop Offset="0.848" />
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="FontSize" Value="14" />
        </DataTrigger>
    </Style.Triggers>
</Style>

<Style TargetType="{x:Type TabItem}" BasedOn="{StaticResource  TabItemStyle}"></Style>

but it does not seem to do anything. Please Help....

Hello

Try change the template completely :
http://msdn.microsoft.com/en-us/library/ms754137%28v=vs.110%29.aspx[^]

Regards
Joseph Leung