WPF 中如何处理字体大小?
我正在创建一个触摸屏优化的应用程序。有相当大的按钮,里面有标签。一般来说,文本大小应该适合按钮提供的空间,因为该应用程序需要处理不同的显示分辨率。
我通过使用 ViewBox 作为父控件实现了这种效果。但这仍然很难看,因为每个按钮的文本大小不同。
我想指定某种“DisplayedCharacters”属性。我通过使用一个自定义类来做到这一点,该类显示固定数量的字符并将文本居中。但当字符数不均匀时,这仍然不完美。
我还有其他方法可以走吗?
I'm creating a touchscreen-optimized application. There are quite large buttons with labels inside of them. Generally, the text size should fit to the space the buttons provides, because this application needs to deal with different display resolutions.
I've achieved this effect by using a ViewBox as parent control. But this is still ugly, because each buttons text is of different size.
I would like to specify some kind of "DisplayedCharacters"-Property. I did this by using a custom class which displays a fxed number of characters and centered the text inside. But that still isn't perfect, when the charcater count is uneven.
Is there any other way I can go for?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是 Microsoft Surface 排版设计指南:http: //msdn.microsoft.com/en-us/library/ff318626(v=Surface.10).aspx
要回答您的具体问题,请选择适合您的所有字体大小按钮。不要在不同的按钮上使用不同的尺寸。字体大小向用户表明什么是最重要的——这很少与字符串长度相关。
比文字更重要的是图像。用适当的图标补充每个按钮上的标签。这些将帮助用户快速直观地决定按下什么,而无需进行大量阅读或思考 - 这是实现触摸可用性目标的更有效方法,比您可以想出的任何文本增强功能都要有效。
Here are the Microsoft Surface design guidelines for typography: http://msdn.microsoft.com/en-us/library/ff318626(v=Surface.10).aspx
To answer your specific question, pick a font size that fits well with all your buttons. Don't use different sizes on different buttons. Font size indicates to users what is most important - this rarely correlates with string lengths.
More important than text is iconography. Supplement the labels on each button with appropriate icons. These will help users quickly and intuitively decide what to press without a lot of reading or thinking - a far more effective way of achieving your touch usability goals than any textual enhancements you could come up with.
我认为你应该换个方式做。您无需调整字体大小,而是调整控件大小。 WPF 和 Silverlight 布局系统是专门为这种情况设计的,如果您正确设计布局,整个 UI 将根据控件的文本和内容而改变。
I think you should do it other way around. Instead of resizing font, you resize the control. WPF and Silverlight layout system is specificaly designed for this case and if you design your layout correctly, the whole UI will change depending on text and content of your controls.