在 WPF 选项卡控件中将选项卡项文本设置为粗体

问题描述:

当我将选项卡项字体粗细设置为粗体时,该选项卡中的所有控件都变为粗体.如何在不影响控件的情况下只设置选项卡项的文本标题?

When I set my tab item font weight to bold, all the controls within that tab become bold. How do I set just the text header of the tab item without affecting the controls?

这是我为使其正常工作所做的工作.谢谢 SeeSharp 的提示.

This is what I did to get it to work. Thanks, SeeSharp, for the hint.

            <TabControl.Resources>
            <Style TargetType="{x:Type TabItem}">
                <Setter Property="HeaderTemplate">
                    <Setter.Value>
                            <DataTemplate>
                                <TextBlock FontWeight="Bold" Text="{Binding}"/>
                            </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            </TabControl.Resources>