问题
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?
回答1:
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>
回答2:
Use ItemTemplate to set template for tab header. Example:
<TabControl ItemsSource="{Binding Items}">
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock FontWeight="UltraBold" Text="{Binding Caption}"/>
</DataTemplate>
</TabControl.ItemTemplate>
来源:https://stackoverflow.com/questions/4677840/set-the-tab-item-text-as-bold-in-wpf-tab-control