Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TextBoxBase.AcceptsReturn Property

Gets or sets a value that indicates how the text editing control responds when the user presses the ENTER key.

Namespace:  System.Windows.Controls.Primitives
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
public bool AcceptsReturn { get; set; }
<object AcceptsReturn="bool" .../>

Property Value

Type: System.Boolean
true if pressing the ENTER key inserts a new line at the current cursor position; otherwise, the ENTER key is ignored. The default value is false for TextBox and true for RichTextBox.

Identifier field

AcceptsReturnProperty

Metadata properties set to true

None

The ENTER key corresponds to VK_RETURN virtual-key code.

This example shows how to use Extensible Application Markup Language (XAML) to define a TextBox control that will automatically expand to accommodate multiple lines of text.

Setting the TextWrapping attribute to Wrap will cause entered text to wrap to a new line when the edge of the TextBox control is reached, automatically expanding the TextBox control to include room for a new line, if necessary.

Setting the AcceptsReturn attribute to true causes a new line to be inserted when the RETURN key is pressed, once again automatically expanding the TextBox to include room for a new line, if necessary.

The VerticalScrollBarVisibility attribute adds a scroll bar to the TextBox, so that the contents of the TextBox can be scrolled through if the TextBox expands beyond the size of the frame or window that encloses it.

<TextBox
  Name="tbMultiLine"
  TextWrapping="Wrap"
  AcceptsReturn="True"
  VerticalScrollBarVisibility="Visible"
>
  This TextBox will allow the user to enter multiple lines of text.  When the RETURN key is pressed, 
  or when typed text reaches the edge of the text box, a new line is automatically inserted.
</TextBox>

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft. All rights reserved.