如何更改 Mahapps.MetroWindow 中 Window 标题的 FontWeigth

How to change FontWeigth of Window Title in Mahapps.MetroWindow

我无法更改 MetroWindow 标题中的字体粗细。我怎样才能做到这一点? 我可以在 MetroWindow 属性中设置 FontWeihgt,但它会影响我 XAML 代码中的所有控件...

您可以设置 TitleTemplate 属性 的 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>

或标题大写:

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