#923 – Text Wrapping in a TextBox
October 8, 2013 3 Comments
By default, the text displayed in a TextBox does not wrap to multiple lines–even if the TextBox is tall enough to accommodate several lines.
<TextBox Text="{Binding NerdQuote}" Height="60"/>
By default, the value of the TextWrapping property of the TextBox is NoWrap. You can set it to Wrap to cause the text to automatically wrap to multiple lines.
<TextBox Text="{Binding NerdQuote}" TextWrapping="Wrap" Height="60"/>
When the TextBox wraps text, it tries to wrap at word boundaries, i.e. after seeing a space or hyphen (-).
If the TextBox is unable to wrap the text, however, it will just wrap at the nearest character.
Notice also that, if text wrapping is enabled, the wrapping will change dynamically as you resize the TextBox.