#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