对于 WPF 默认系统字体,如何在资源字典中指定默认系统字体

For WPF default System Font how can I specify the default system font in a resource dictionary

在资源字典中,有没有一种方法可以声明默认的系统字体家族是所需的,而不必声明特定的系统字体家族(即 Segoe UI)?

如果有以下声明:

<FontFamily x:Key="<some key string>" > xxx </FontFamily>

我用什么代替 xxx 来指定默认的系统字体系列 (System.Media.Windows)?

<FontFamily.FamilyNames>
    <System:String x:Key="en-US">Comic San Serif</System:String>
</FontFamily.FamilyNames>

更多详情here

In a resource dictionary, is there a way to declare that the default System FontFamily is what is desired without having to declare a specific System FontFamily (i.e. Segoe UI) ?

简短回答:不。不在 XAML。

您可以以编程方式创建您的资源:

Resources.Add("someKey", SystemFonts.CaptionFontFamily);

或者直接使用 SystemFonts class 中的现有资源而不创建您自己的资源,例如:

<TextBlock Text="Sample text..." FontFamily="{x:Static SystemFonts.CaptionFontFamily}" />