浮点数的整数部分和小数部分的不同字体大小

发布于 2025-01-07 14:47:46 字数 275 浏览 4 评论 0原文

我想使用较小的字体大小显示(例如在 TextBlock 中)浮点数的小数部分,如下所示:

enter image此处的描述

浮点值来自绑定,因此它不是静态文本。

我目前在 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:

enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩套路吗 2025-01-14 14:47:46

一种改进的想法:只有一个转换器和一个转换器参数来获取整数或小数部分。 (或者积分没有参数,分数用“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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文