Is there a way of wrapping text in a non-rectangular container in WPF?
Here is how it is done in photoshop
Have you looked at the UIElement.Clip property?
For non-rectangular text wrapping, you could try setting a TextBlock.Clip property to a non-rectangular Geometry object. I haven't tried this; either it will not draw text outside the clip region or it will wrap text to fit within the clip.
Charles Petzold mentions this technique.
Unfortunately there isn't a straightforward way without making a complete implementation of a TextFormatter. MSDN article on the basics of an Advanced TextFormatter:
The text layout and UI controls in WPF provide formatting properties that allow you to easily include formatted text in your application. These controls expose a number of properties to handle the presentation of text, which includes its typeface, size, and color. Under ordinary circumstances, these controls can handle the majority of text presentation in your application. However, some advanced scenarios require the control of text storage as well as text presentation. WPF provides an extensible text formatting engine for this purpose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With