如何改变所选标签的样式 [英] How to cahnge the style of selected tab
本文介绍了如何改变所选标签的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码更改所选标签的样式
< pre lang = xml > < 样式 TargetType = {x:Type TabItem} x:密钥 = TabItemStyle >
< Style .Triggers>
< DataTrigger Binding ={绑定 IsSelected,RelativeSource = {RelativeSource AncestorType = TabItem} }Value =True>
< Setter Property =Background>
<设置器跨度>。价值>
< LinearGradientBrush EndPoint =1, 0 .5StartPoint =0,< span class =code-leadattribute> 0 .5>
< GradientStop Color =LightBlueOffset =0/>
< GradientStop Color =BlanchedAlmondOffset =1/>
< GradientStop Color =#A50000C9Offset =0.376/>
< GradientStop Offset =0.848/>
< / LinearGradientBrush >
< / Setter.Value >
< / Setter >
< Setter 属性 = FontSize 值 = < span class =code-keyword> 18 / >
< / DataTrigger >
< DataTrigger Binding = {Binding IsSelected,RelativeSource = {RelativeSource AncestorType = TabItem}} 值 = < span class =code-keyword> False >
< Setter Property = 背景 >
< span class =code-keyword>< Setter.Value >
< LinearGradientBrush EndPoint = 1,0.5 StartPoint = 0,0.5 >
< GradientStop 颜色 = LightGray < span class =code-attribute> Offset = 0 / >
< GradientStop 颜色 = DarkOrange 偏移量 = 1 / >
< GradientStop 颜色 = #A50000C9 偏移量 = 0.376 / >
< GradientStop 偏移量 = 0.848 / >
< / LinearGradientBrush >
< / Setter.Value >
< / Setter >
< Setter 属性 = FontSize 值 = 14 / >
< / DataTrigger > ;
< / Style.Triggers >
< / Style >
< 样式 TargetType = {x:Type TabItem} BasedOn = {StaticResource TabItemStyle} > < / 样式 >
但它似乎没有做任何事情。请帮助....
解决方案
您好
尝试完全更改模板:
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
这篇关于如何改变所选标签的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文