如何更改 TabItem 的标题字体而不更改内容的字体?

12

如何在 TabItem 的标题中更改字体而不更改内容的字体?当我在 TabItem 中设置 FontSize 属性时,它也会更改 TextBlock 上的字体大小。

<Window x:Class="WpfApplication4.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Height="350" Width="525">
    <TabControl>
        <TabItem Header="item1">
            <TextBlock Text="test" Margin="20" />
        </TabItem>
        <TabItem Header="item2" FontSize="20">
            <TextBlock Text="test" Margin="20" />
        </TabItem>
    </TabControl>
</Window>
1个回答

22
可以像这样操作 -
        <TabControl>
            <TabItem>
                <TabItem.Header>
                    <TextBlock Text="Tab1" FontSize="23" />
                </TabItem.Header>
                <TextBlock Text="Content" />
            </TabItem>
        </TabControl>

此解决方案仅在未应用任何主题时起作用。 - Martin Kirk

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接