wpfxamlmahapps.metro

How to change FontWeigth of Window Title in Mahapps.MetroWindow


I can not change Font Weight in MetroWindow Title. How can i do this? I can set FontWeihgt in MetroWindow Attributes, but it affect all controls in my XAML code...


Solution

  • You can set the TitleTemplate property of the MetroWindow.

    <Controls:MetroWindow.TitleTemplate>
        <DataTemplate>
            <TextBlock Text="{TemplateBinding Content}"
                       TextTrimming="CharacterEllipsis"
                       VerticalAlignment="Center"
                       Margin="8 -1 8 0"
                       FontWeight="Light"
                       FontSize="{DynamicResource WindowTitleFontSize}"
                       FontFamily="{DynamicResource HeaderFontFamily}" />
        </DataTemplate>
    </Controls:MetroWindow.TitleTemplate>
    

    Or with upper case for the title:

    <Controls:MetroWindow.TitleTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content, Converter={Converters:ToUpperConverter}}"
                       TextTrimming="CharacterEllipsis"
                       VerticalAlignment="Center"
                       Margin="8 -1 8 0"
                       FontWeight="Light"
                       FontSize="{DynamicResource WindowTitleFontSize}"
                       FontFamily="{DynamicResource HeaderFontFamily}" />
        </DataTemplate>
    </Controls:MetroWindow.TitleTemplate>