Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize TabItem header size inside TabControl

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.

like image 392
berry wer Avatar asked Aug 02 '15 09:08

berry wer


4 Answers

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>
like image 180
Hadiro Tafoua Avatar answered Oct 09 '22 07:10

Hadiro Tafoua


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.

like image 25
punker76 Avatar answered Nov 01 '22 14:11

punker76


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.

like image 6
Andrej Kmetík Avatar answered Nov 01 '22 14:11

Andrej Kmetík


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.

like image 3
Praveen M B Avatar answered Nov 01 '22 14:11

Praveen M B