#929 – Allowing Multiline Input in a TextBox

You can configure a TextBox to automatically wrap lines of text to multiple lines by setting the TextWrapping property to Wrap or WrapWithOverflow.  You can visually show that a TextBox has more lines than currently fit into the visible region of the TextBox by setting the VerticalScrollBarVisibility property to Auto or Visible.

With these properties set, the text that a user enters into the TextBox will automatically wrap when the user reaches the edge of the TextBox.

929-001

If you also want the user to be able to press Enter or Return to move to a new line, you can set the AcceptsReturn property to true.

        <TextBox Grid.Row="1" Margin="5"
                 HorizontalAlignment="Stretch"
                 TextWrapping="Wrap"
                 AcceptsReturn="True"
                 VerticalScrollBarVisibility="Auto"/>

With both TextWrapping set to Wrap and AcceptsReturn set to true, text will wrap to the next line if the edge of the TextBox is reached or if the user presses Enter.

929-002

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

One Response to #929 – Allowing Multiline Input in a TextBox

  1. Pingback: Dew Drop – October 16, 2013 (1,646) | Morning Dew

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: