Reputation: 2963
I do not know how to describe my problem, but imagine having a TextBox in WPF with a long text. I have set TextWrapping="Wrap"
to prevent the whole string being displayed in one line, but I want my sting to be shown as follows:
Lorem ipsum dolor sit amet, consectetur adipiscing el
it. Fusce ligula nulla, cursus finibus mauris vel, rh
oncus blandit sem. Fusce fermentum sed sem a porttito
r. Proin id convallis ex.
Instead of this:
Lorem ipsum dolor sit amet, consectetur adipiscing
elit. Fusce ligula nulla, cursus finibus mauris vel,
rhoncus blandit sem. Fusce fermentum sed sem a
porttitor. Proin id convallis ex.
The difference is, that the first text has a 'hard cut' after every n character - the second text is wrapped, that each line does not exceed a length of n characters
Do I have to insert a \n
after every n-th character, or is there a WPF-property, which can solve this for me?
Thank you very much and merry christmas to you all :)
Upvotes: 10
Views: 1257
Reputation: 2741
Just try it with TextAlignment="Justify"
<TextBox TextAlignment="Justify" TextWrapping="Wrap" Height="250" MinWidth="250" Width="250" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce ligula nulla, cursus finibus mauris vel, rhoncus blandit sem. Fusce fermentum sed sem a porttitor. Proin id convallis ex."/>
Upvotes: 1
Reputation: 353
I don't think there is a direct property to achieve the result. TextTrimming
property is available only for TextBlock
. It is better to add linebreak to achieve the result.
Upvotes: 3