WPF Metro 设计:如何将字符大小写与 Style 一起应用?
我正在尝试按照 Metro 设计原则在 WPF 中开发 UI - 请参阅 Scott Barnes 网站进行精彩调查。
字符大小写是Metro里程碑之一,可以使用text-transform属性在css中轻松实现。
WPF 控件怎么样?
在资源文件中声明菜单、标题、副标题的各种样式,并通过简单地编辑应用的样式来修改大小写将很有用。
笔记:
[1] TextBox.CharacterCasing 不适用,它仅涉及手动输入的字符。
[2] 我无法想象一个适合这项任务的值转换器。
I'm trying to develop a UI in WPF following Metro design principles - see Scott Barnes website for a great survey.
Character casing is one of Metro milestone, which can be easily achieved in css using text-transform property.
What about WPF control?
It would be useful to declare various style for menu, title, subtitle in a resource file, and modify casing by simply editing the applied style.
Note:
[1] TextBox.CharacterCasing doesn't apply, it involves only manually entered characters.
[2] I can't imagine an appropriate value converter for this task.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有几种方法可以实现这一点。根据具体情况,您可能需要所有大写或小写字符。您可以轻松应用 ValueConverter,它将应用逻辑并返回一个值。
这种类型的实现的简单示例:
转换器逻辑:
对于高级排版选项,如连字、下标/上标、花体字等,您需要兼容的 OpenType 字体。请参阅这篇 MSDN 文章,了解可能发生的情况。
There are a couple approaches to this. On a per-case basis you may want all upper or lower case characters. You can easily apply a ValueConverter which will apply logic and return a value.
Quick example of this type of implementation:
And the converter logic:
For advanced typography options like ligatures, subscript/superscript, swashes, etcetera., you'll need a compatible OpenType font. See this MSDN article to see what's possible.