Overwrite Mahapps Metro style for me Tabitem title

I work with WPF and MVVM. I installed Mahapps Metro, this nuget package provides all the styles for my application.

I made a TabControl, but the FontSize that Mahapps uses for the title in each TabItem is very large for my application.

I need to create a StaticResource that modifies the FontSize of the header in the TabItem without removing the other properties that Mahapps provides.

+4
source share
2 answers

Put the following code in your window resources, for example:

<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="24"></Setter>
        </Style>
<Window.Resources>

[https://github.com/MahApps/MahApps.Metro/blob/master/MahApps.Metro/Styles/Controls.TabControl.xaml, 158] , , , Content Presenter. ControlsHelper.HeaderFontSize.

+12

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

TabItem .

<TabItem Header="Dimension Alias" Style="{DynamicResource MenuLevel2}">

.

+1

Source: https://habr.com/ru/post/1538655/


All Articles