I am using MahApps
TabControl
and i have several TabItems
:
<TabControl Name="tabControl" FontSize="12">
<TabItem Header="Statistics" />
</TabControl>
I try to change the font
size of the TabControl
and TabItems
in order to resize my headers but it seems that this not changing anything.
since tabItems is a list of item having some common bindings modifying one of Tabitem header height will automatically do for the others
<TabControl>
<TabItem >
<TabItem.Header>
<Label Height="30" Content="Main" FontSize="16" >
</Label>
</TabItem.Header>
</TabItem>
<TabItem Header="Second header" >
<TabItem Header="Third header" >
</TabControl>
You should use the attached property HeaderFontSize
to set the header font size of the tav items.
<TabControl Name="tabControl">
<TabItem Header="Statistics" Controls:ControlsHelper.HeaderFontSize="12" />
</TabControl>
or
<TabControl Name="tabControl">
<TabControl.Resources>
<Style TargetType="{x:Type TabItem}" BasedOn="{StaticResource {x:Type TabItem}}">
<Setter Property="Controls:ControlsHelper.HeaderFontSize" Value="12" />
</Style>
</TabControl.Resources>
<TabItem Header="Statistics" />
</TabControl>
Hope that helps.
In 2.* versions of MahApps.Metro it changes to:
<TabControl Name="tabControl">
<TabItem Header="Statistics" Controls:HeaderedControlHelper.HeaderFontSize="12" />
</TabControl>
or
<TabControl Name="tabControl">
<TabControl.Resources>
<Style TargetType="{x:Type TabItem}" BasedOn="{StaticResource {x:Type TabItem}}">
<Setter Property="Controls:HeaderedControlHelper.HeaderFontSize" Value="12" />
</Style>
</TabControl.Resources>
<TabItem Header="Statistics" />
</TabControl>
Source: https://github.com/MahApps/MahApps.Metro/issues/3711
Documentation is not available at the time of writing.
Put the below code in Window.Resources
<Window
......
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
......
>
<Window.Resources>
<Style x:Key="MenuLevel2" BasedOn="{StaticResource MetroTabItem}" TargetType="{x:Type TabItem}">
<Setter Property="mah:ControlsHelper.HeaderFontSize" Value="15"></Setter>
</Style>
<Window.Resources>
In the TabItem section add the style details.
<TabItem Header="Dimension Alias" Style="{DynamicResource MenuLevel2}">
This worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With