浮点数的整数部分和小数部分的不同字体大小
我想使用较小的字体大小显示(例如在 TextBlock 中)浮点数的小数部分,如下所示:
浮点值来自绑定,因此它不是静态文本。
我目前在 TextBlock 内使用两个具有不同字体大小的 Run 对象 - 每个对象都绑定到相同的浮点值,并分别带有返回整数和小数部分的转换器。但我不喜欢这涉及两个绑定。
有没有更好的方法来达到相同的结果?
I'd like to display (e.g. in a TextBlock) the fractional part of a float using a smaller font size like this:
The float value comes from a binding, so it's not static text.
I'm currently using two Run objects with different font sizes inside a TextBlock -- each of which have a binding to the same float value with converters that return the integral, and the fractional part, respectively. But I don't like that this involves two bindings.
Is there a better way to achieve the same result?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种改进的想法:只有一个转换器和一个转换器参数来获取整数或小数部分。 (或者积分没有参数,分数用“frac”)。
one idea of improvement : only one converter, and a converter parameter to get either integral or fractional part. (or no parameter for integral, and 'frac' for fractional).