如何更改文本框中 XAML 中的字符间距?
如何更改 WPF 应用程序中文本块内的字符间距。也称为字符字距调整或跟踪。
How do I change the character spacing in a WPF application within a textblock. Also known as kerning or tracking for characters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
social.msdn 上的答案 建议使用
字形
。除此之外
FontStretch
允许进行一些调整。An answer on social.msdn suggests the use of
Glyphs
.Other than that
FontStretch
allows for some adjustment.也许您可以为该文本框添加一个行为,该行为将遍历每个字符并在其后添加一个空格。
或者,如果您使用数据绑定,请使用具有相同逻辑的转换器。
如果你想要过度杀伤,你可以创建一个自定义控件,它将继承自 TextBox 并实现该间距逻辑
这还允许您添加依赖属性,例如“NumOfSpaces”
你可以控制它会放置多少个空格
Maybe you can add a Behavior for that TextBox that would go over every character and add a space after it.
Alternatively, If you're using DataBinding, use a Converter with the same logic.
And if you want to go for an overkill, you can make a custom control, that will inherit from TextBox and implement that spacing logic
That would also allow you to add a Dependency Property, something like "NumOfSpaces"
and you could control how many spaces it would put