WPF应用程序调整屏幕和字体设置(或者,我如何将涉及的DLU的单位在WPF?)如何将、应用程序、屏幕、字体

2023-09-03 21:14:09 作者:艹

在MFC中,对话框用的DLU 设计。在WPF中,我们以1 / 96inch单位指定。虽然这的确是规模的Windows和视觉元素,我们怎样才能使WPF尊重用户当前的字体设置?如果我们指定一个特定的字体使用,并坚持该字体?

In MFC, dialog boxes were designed using DLUs. In WPF, we specify in 1/96inch units. While this would indeed scale windows and visual elements, how do we make make WPF "respect" the current font settings of the user? Should we specify a certain font to be used and stick to that font?

如何将一去布局,荷兰国际集团是很乖的应用程序

How would one go about layout-ing a "well behaved application"

调整窗口大小以适应当前字体设置和分辨率 对于小屏幕在回流/布局窗口/文字优雅。

任何帮助或指导将AP preciated? (Windows用户体验指南清楚什么应该发生,但现在它如何能在WPF中实现)。

Any help or guidelines would be appreciated? (Windows User Experience Guidelines is clear about what should happen, but now how it could be implemented in WPF).

推荐答案

我们处理这个应用的字体大小和样式设置在WPF界面中的所有文本对象。这是可以实现在运行时,也可以修改在飞行。有一件事你必须真正要小心的却是用户界面的布局。它必须是多个流体(动态)时允许这种类型的定制。我通常有最低大小为我的窗口和控制设置,以帮助满足这一点。堆叠/包裹面板可以让这个更容易实现。还利用网格带*记号可以允许文本框和标签按需扩展。

We handle this by applying the font size and style settings to all text objects in the WPF UI. This can be accomplished at run time and can also be modified on the fly. One thing you have to really be careful of however is the layout of the UI. It has to be more fluid (dynamic) when allowing this type of customization. I normally have minimum sizes set for my windows and controls to help accommodate this. Stack / Wrap Panels can make this easier to accomplish. Also using Grids with * notation can allow for text boxes and labels to expand as needed.

请注意,这也是创建本地化应用程序时,某些语言翻译成更长的字符串,从而结束和调整是非常关键的一个要求。

Note this is also a requirement when creating localized applications as certain languages translate into much longer strings thus wrapping and resizing is critical.