在 WPF 选项卡控件中将选项卡项文本设置为粗体 [英] Set the tab item text as bold in WPF tab control

查看:51
本文介绍了在 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>

这篇关于在 WPF 选项卡控件中将选项卡项文本设置为粗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆