7

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

Timbioz
  • 175
  • 3
  • 8

2 Answers2

14

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>
punker76
  • 14,326
  • 5
  • 58
  • 96
0

Just to update the answer of @punker76, in ver. 2.x resources are renamed, so the example would be

<mah:MetroWindow.TitleTemplate>
   <DataTemplate>
      <TextBlock Text="{TemplateBinding Content}"
                 TextTrimming="CharacterEllipsis"
                 VerticalAlignment="Center"
                 Margin="8 -1 8 0"
                 FontWeight="Normal"
                 FontSize="{DynamicResource MahApps.Font.Size.Window.Title}"
                 FontFamily="{DynamicResource MahApps.Fonts.Family.Window.Title}" />
   </DataTemplate>
</mah:MetroWindow.TitleTemplate>
Misho73bg
  • 38
  • 2
  • 4