下划线活动标签

时间:2016-10-19 15:58:36

标签: wpf vb.net tabitem

我想用粗线为活动标签加下划线并使其成为蓝绿色。当选项卡处于非活动状态时,下划线应该消失。到目前为止我所拥有的是每个标签下的下划线,但我不知道如何关闭/打开它取决于它是否有效。

                <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>

由于

1 个答案:

答案 0 :(得分:1)

试试这个。

<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>