0

I work with several languages where some words are longer than the textblocks that display them. The strings are displayed in different textblocks with different width, so I can't just manually wrap them. The correct way to wrap them is at certain places in the word using a hyphen. To my knowledge those places are normally marked with special characters, for example in the case of epubs.

I thought that this special character would simply be a zero-width space, which wraps the word just fine in WPF, but the textblock is them missing the hyphen that signals the reader that the word is wrapped, and not that those are two different words.

Is there some other special character that can be used in WPF to correctly wrap long words, or do I have to write my own behaviour for this?

Gregor A. Lamche
  • 402
  • 2
  • 5
  • 18
  • Possible duplicate of [How can I wrap text in a label using WPF?](https://stackoverflow.com/questions/5013067/how-can-i-wrap-text-in-a-label-using-wpf) – MindSwipe Jul 17 '19 at 13:14
  • No, the linked one is about wrapping a text in general, and not about wrapping long words and automatically adding a hyphen. The textblock instead of label doesn't help. Actually, the label already is a textblock, I'll fix that in my question. – Gregor A. Lamche Jul 17 '19 at 13:27
  • The answer is still relevant. You can just replace `TextWrapping="WrapWithOverflow"` with `TextWrapping="Wrap"` as described [here](https://stackoverflow.com/a/7348998/9363973) – MindSwipe Jul 17 '19 at 13:30
  • No, because it breaks the word at the wrong place. It's like breaking "textbloc|k" instead of "text|block", in this example a lone 'k' in it's own line. I can tell it to break between text and block with a zero-width space, but then the hyphen is missing that should be there. – Gregor A. Lamche Jul 17 '19 at 13:33
  • 1
    You may be interested in this: https://en.m.wikipedia.org/wiki/Soft_hyphen – dumetrulo Jul 17 '19 at 14:01
  • This seems to be exactly what I need, if you add this as an answer I can flag it as such. (best add the alt code ALT+0173 so it's easy to use for people who have the same problem). – Gregor A. Lamche Jul 17 '19 at 14:55

1 Answers1

1

It would appear that you are looking for a soft hyphen or syllable hyphen. Please see https://en.wikipedia.org/wiki/Soft_hyphen for more info.

dumetrulo
  • 1,993
  • 9
  • 11