Mahapps.metro: Title Bar Font Size

Created on 14 May 2014  路  8Comments  路  Source: MahApps/MahApps.Metro

How can I change the Title Bar font size? I applied the CleanWindow style as follows:

<ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Steel.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Clean/CleanWindow.xaml"/>
            </ResourceDictionary.MergedDictionaries>

So now the title bar font is centered and there is no background color (both are what I want), but I lost the icon in the top left.
2014-05-13 21_06_17-cmc installer v1 0 36097

Question

Most helpful comment

Thanks. This got me closer:

<Application x:Class="Cmc.Installer.App.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:system="clr-namespace:System;assembly=mscorlib">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Steel.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Clean/CleanWindow.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <system:Double x:Key="WindowTitleFontSize">12</system:Double>
            <FontFamily x:Key="HeaderFontFamily">Segoe UI</FontFamily>
        </ResourceDictionary>        
    </Application.Resources>
</Application>

I still don't have my top left icon anymore though. I think CleanWindow.xaml did that.

All 8 comments

Commenting out <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> reverts to the WPF default font size, but that doesn't seem like the right approach.

@mrichman you can (re)set the titlebar font size in your app.xaml after the mahapps resource dict

 <System:Double x:Key="WindowTitleFontSize">16</System:Double>

Thanks. This got me closer:

<Application x:Class="Cmc.Installer.App.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:system="clr-namespace:System;assembly=mscorlib">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Steel.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Clean/CleanWindow.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <system:Double x:Key="WindowTitleFontSize">12</system:Double>
            <FontFamily x:Key="HeaderFontFamily">Segoe UI</FontFamily>
        </ResourceDictionary>        
    </Application.Resources>
</Application>

I still don't have my top left icon anymore though. I think CleanWindow.xaml did that.

How are you setting the icon?

My mistake. It's displaying the icon, but it's stretched to fill the height of the title bar. Any way to fix that?

<controls:MetroWindow x:Class="Cmc.Installer.App.Views.ShellView"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                      xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
                      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                      xmlns:views="clr-namespace:Cmc.Installer.App.Views"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      mc:Ignorable="d"
                      BorderThickness="1"
                      BorderBrush="Gray"
                      EnableDWMDropShadow="True"
                      Height="768"
                      Icon="..\Images\campusvue_student_Icon.ico"
                      MinHeight="600"
                      MinWidth="800"
                      RenderOptions.ClearTypeHint="Enabled"
                      ResizeMode="CanResizeWithGrip"
                      ShowIconOnTitleBar="True"
                      Style="{DynamicResource CleanWindowStyleKey}"
                      TextOptions.TextFormattingMode="Display"
                      Title="{Binding Path=AppTitle}"
                      TitleCaps="False"
                      Width="1024"
                      WindowStartupLocation="CenterScreen">

2014-05-16 09_26_13-cmc installer debug_mixed platforms - microsoft visual studio administrator

Set the IconTemplate to an Image object with Stretch set to Uniform.

Thanks! This worked pretty well:

<controls:MetroWindow.IconTemplate>
        <DataTemplate>
            <Image Stretch="Uniform" Source="../Images/cvIcon_v1.png" />
        </DataTemplate>
    </controls:MetroWindow.IconTemplate>

Came here looking for the very same thing and found out that it changed from WindowTitleFontSize to MahApps.Font.Size.Window.Title.

You can find all the relevant options here.

Sorry for necro'ing the issue, but just leaving this here for future readers.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nova669 picture Nova669  路  3Comments

bplatypus picture bplatypus  路  3Comments

punker76 picture punker76  路  4Comments

dxdx347 picture dxdx347  路  5Comments

Zebody picture Zebody  路  4Comments