#923 – Text Wrapping in a TextBox

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}"

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}"

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.923-005923-006


About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

3 Responses to #923 – Text Wrapping in a TextBox

  1. Pingback: Dew Drop – October 8, 2013 (#1,640) | Morning Dew

  2. Pingback: #924 – TextBox Wrap vs. WrapWithOverflow | 2,000 Things You Should Know About WPF

  3. Pingback: #929 – Allowing Multiline Input in a TextBox | 2,000 Things You Should Know About WPF

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: