silverlight字符串格式限制字符数

发布于 2025-01-06 05:46:01 字数 188 浏览 3 评论 0原文

我正在使用 SubString 方法来限制字符数。这可以在 XAML 中实现吗?如果是这样,如何设置格式字符串来限制 XAML 中的字符数,如 String.Format

例如:

我的大短信 ->我的大文本....

I am using the SubString method to limit the character count. Is this possible to do in XAML? If so, how do you set the format string to limit the character count in XAML as in String.Format

For example:

My Big text Message -> My Big text....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

枯寂 2025-01-13 05:46:01

使用 TextTrimming Silverlight 4 中 TextBlock属性应该可以工作:

<TextBlock TextTrimming="WordEllipsis"/>

这样做的好处是它将使用实际的文本测量而不是任意字符计数,因为显然并非所有字符都是宽度相同。

Using the TextTrimming property of TextBlock in Silverlight 4 should work:

<TextBlock TextTrimming="WordEllipsis"/>

What's nice about this is that it will use actual text measurements instead of arbitrary character counts, since obviously not all characters are the same width.

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