WPF TextBlock 自定义换行:位于左侧“.”之后

发布于 2024-09-11 02:39:30 字数 349 浏览 1 评论 0原文

我正在尝试显示一个将在左侧换行并且仅在字符串中的特殊字符之后换行的文本。

我希望第一部分可以在 XAML 中完成,并且我很确定第二部分不能。

目的是以这种方式换行文本:
- 原始文本:“Object1.Object2.Object3.Property1”
- 换行文本可能是(取决于文本可用的宽度):
- - “....对象2.对象3.属性1”
- - “....Object3.Property1”
- - “....Property1”

你知道该怎么做吗?我尝试使用 TextBlock“TextWrapping”和“TextTrimming”属性,但没有成功。

谢谢您的回答

I'm trying to display a text that would be wrapped on the left and only after special characters in the string.

I Hope the first part could be done in XAML, and I'm pretty sure the second part cannot.

The aim is to wrap a text this way :
- Original text : "Object1.Object2.Object3.Property1"
- Wrapped text could be (depending on the width available for the text):
- - "....Object2.Object3.Property1"
- - "....Object3.Property1"
- - "....Property1"

Do you know anyway to do that? I tried to use the TextBlock "TextWrapping" and "TextTrimming" properties, without success.

Thank you for your answers

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

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

发布评论

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

评论(1

人间不值得 2024-09-18 02:39:30

您无法使用 TextWrapping 或其他 WPF 属性来执行此操作。相反,您可以编写自定义 转换器并将文本块的宽度作为 绑定参数

You cannot do that with TextWrapping nor another WPF property. Instead you can write a custom converter and send the width of textblock as a binding parameter.

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