10

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.

berry wer
  • 637
  • 2
  • 12
  • 25

6 Answers6

25

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.

punker76
  • 14,326
  • 5
  • 58
  • 96
6

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.

Andrej Kmetík
  • 158
  • 3
  • 10
3

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.

Praveen M B
  • 187
  • 2
  • 3
2

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>
1

In my case this has solved my problem:

<TabControl>
    <TabControl.Resources>
        <Style TargetType="{x:Type TabItem}" BasedOn="{StaticResource {x:Type TabItem}}">
            <Setter Property="Controls:ControlsHelper.HeaderFontSize" Value="12" />
        </Style>
    </TabControl.Resources>
</TabControl>
Marco Concas
  • 1,665
  • 20
  • 25
1

Since 2.0 we have to use this in your App.xaml or directly in the resources of your control:

<System:Double x:Key="MahApps.Font.Size.TabItem">16.67</System:Double>
Suplanus
  • 1,523
  • 16
  • 30