如何全局更改 C# WPF 中的字体大小?
How do I globally change the Font Size in C# WPF?
好的,所以我正在尝试通过 XAML
在我的一个程序中进行 全局 更改。我所做的第一个更改是 Font Family
似乎工作正常,我只是放了类似的东西:
<Windows
FontFamily = "Calibri"
</Window >
当我为 TextBoxes 和 Labels[=] 的所有 FontSizes 实施相同的过程时26=] 我试过了:
<Windows
FontFamily = "Calibri"
FontSize = "18"
</Window >
一切似乎都正常,但是当我点击 XAML 上的那个特定元素,然后点击文本并查看字体大小时,它实际上是 13.5pt.这里到底发生了什么?不应该是18吗?
这个主题涵盖得相当透彻here。
该线程还为您提供了一些您可能感兴趣的替代实现。特别是在回答您的问题时:
TextElement.FontSize is an inherit property, which means you can simply set the font size at root element, and all the children elements will use that size (as long as you don't change them manually)
您仍然会在设计器中看到字体大小的默认规范,除非您覆盖它,但在 运行 时,控件应该从您的全局设置中继承正确的值。
好的,所以我正在尝试通过 XAML
在我的一个程序中进行 全局 更改。我所做的第一个更改是 Font Family
似乎工作正常,我只是放了类似的东西:
<Windows
FontFamily = "Calibri"
</Window >
当我为 TextBoxes 和 Labels[=] 的所有 FontSizes 实施相同的过程时26=] 我试过了:
<Windows
FontFamily = "Calibri"
FontSize = "18"
</Window >
一切似乎都正常,但是当我点击 XAML 上的那个特定元素,然后点击文本并查看字体大小时,它实际上是 13.5pt.这里到底发生了什么?不应该是18吗?
这个主题涵盖得相当透彻here。
该线程还为您提供了一些您可能感兴趣的替代实现。特别是在回答您的问题时:
TextElement.FontSize is an inherit property, which means you can simply set the font size at root element, and all the children elements will use that size (as long as you don't change them manually)
您仍然会在设计器中看到字体大小的默认规范,除非您覆盖它,但在 运行 时,控件应该从您的全局设置中继承正确的值。