如何确定WPF窗口的默认字体大小? [英] How is the default font size for a wpf window determined?

查看:445
本文介绍了如何确定WPF窗口的默认字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解在WPF中,除非定义了覆盖,否则控件使用的字体大小由父控件确定.

鉴于我没有在应用程序中的任何地方定义字体大小,因此我假定默认字体大小是为顶级Window配置的字体大小.

此值是否由应用程序运行所在的系统确定(如果是,在哪里?);还是由某个内置的WPF默认值确定(如果是,它是什么?)

解决方案

默认字体大小由TextElement类的FontSize依赖项属性确定: 解决方案

The default font size is determined by the FontSize dependency property of the TextElement class: https://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/Documents/TextElement.cs,e28640b48d79de57. It defaults to SystemFonts.MessageFontSize which has a default value of 12.

The Control base class them adds itself as an owner of this dependency property and defines its own FontSize property that can any control can set to a custom value.

Please refer to the following blog post for more information about this: https://blog.davidpadbury.com/2008/08/30/change-the-default-font-of-a-wpf-application/.

这篇关于如何确定WPF窗口的默认字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆