Is it possible to prevent parentheses at the end of a word from wrapping using the TextBlock and the FlowDock. Example: The next time you decide to author text you should think about having pizza(s). The issue we are having is that the (s). is getting wrapped to the next line. The desired wrapping would be for the entire word pizza(s). to wrap to the next line.
Asked
Active
Viewed 564 times
2
-
Tried `pizza(s)` ? – Chris W. Feb 20 '13 at 21:18
-
I don't think that works for us, the text is coming from a translation database and has to make sense to translators. – codercodecode Feb 20 '13 at 21:55
-
Ya I must have been thinking of some embedded stuff I did awhile back, just tested and it doesnt work anyway. Unfortunately I can't think of how you're going to do this without giving it or its parent a tiny bit more space to work with considering wrapping will take it to a character level if space isnt available. Might refer to; http://stackoverflow.com/questions/7348920/wpf-text-wrap-vs-wrapwithoverflow – Chris W. Feb 20 '13 at 22:09
-
Is there some sort of custom control that could be done to determine when to wrap and when not to? – codercodecode Feb 21 '13 at 16:21
-
Not that I'm aware of sorry. Something you would likely have to make from scratch. – Chris W. Feb 21 '13 at 16:35
1 Answers
1
You can surround special content with an inline container to make sure it is treated as a single element for wrapping purposes. The same trick would work if you wanted to make sure a name like "Bob Johnson" never got split apart.
<TextBlock TextWrapping="Wrap">
The next time you decide to author text you should think about having <TextBlock Text="pizza(s)" />
</TextBlock>
It sounds like in the comments you might be pulling data from an external resource. If that is the case and you want to do it all programmatically, you may want to look at indirectly creating the inlines by using an interactivity behavior or an attached property with a MultiValueConverter that passes the TextBlock. I don't think a direct converter would work because TextBlock.Inlines is not settable.
Hope it helps. :)

Steve Cadwallader
- 2,656
- 4
- 28
- 37