下划线活动选项卡
Underline active tab
我想用粗线在活动选项卡下划线,并将其设为蓝绿色。当标签不活动时,下划线应消失。到目前为止,我在每个选项卡下都有一个下划线,但我不确定如何打开它 off/on 取决于它是否处于活动状态。
<Style TargetType="{x:Type TabItem}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="#48637E" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter Property="Foreground" Value="#B4B4B4" />
</Trigger>
</Style.Triggers>
</Style>
<TabItem>
<TabItem.Header>
<StackPanel >
<TextBlock Text=" FirstTab" FontFamily="Arial" FontSize="14" FontWeight="Bold" />
<TextBlock Text="___________" Foreground="#00A79D" />
</StackPanel>
</TabItem.Header>
</TabItem>
谢谢
试试这个。
<TabControl>
<TabControl.Resources>
<Style TargetType="{x:Type TabItem}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="#48637E" />
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{TemplateBinding Content}" TextDecorations="Underline"></TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter Property="Foreground" Value="#B4B4B4" />
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{TemplateBinding Content}" ></TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</TabControl.Resources>
<TabItem Header="First"></TabItem>
<TabItem Header="Second"></TabItem>
<TabItem Header="Third"></TabItem>
</TabControl>
我想用粗线在活动选项卡下划线,并将其设为蓝绿色。当标签不活动时,下划线应消失。到目前为止,我在每个选项卡下都有一个下划线,但我不确定如何打开它 off/on 取决于它是否处于活动状态。
<Style TargetType="{x:Type TabItem}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="#48637E" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter Property="Foreground" Value="#B4B4B4" />
</Trigger>
</Style.Triggers>
</Style>
<TabItem>
<TabItem.Header>
<StackPanel >
<TextBlock Text=" FirstTab" FontFamily="Arial" FontSize="14" FontWeight="Bold" />
<TextBlock Text="___________" Foreground="#00A79D" />
</StackPanel>
</TabItem.Header>
</TabItem>
谢谢
试试这个。
<TabControl>
<TabControl.Resources>
<Style TargetType="{x:Type TabItem}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="#48637E" />
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{TemplateBinding Content}" TextDecorations="Underline"></TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter Property="Foreground" Value="#B4B4B4" />
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{TemplateBinding Content}" ></TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</TabControl.Resources>
<TabItem Header="First"></TabItem>
<TabItem Header="Second"></TabItem>
<TabItem Header="Third"></TabItem>
</TabControl>