Search code examples
wpftrimtextblockword-wrap

WPF TextBlock custom wrapping : on the left and after a "."


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


Solution

  • 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.