gpt4 book ai didi

wpf - 如何在 Mahapps.MetroWindow 中更改窗口标题的 FontWeigth

转载 作者:行者123 更新时间:2023-12-04 10:48:56 25 4
gpt4 key购买 nike

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

最佳答案

您可以设置 TitleTemplate MetroWindow 的属性(property).

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

关于wpf - 如何在 Mahapps.MetroWindow 中更改窗口标题的 FontWeigth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33712214/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com