Windows apps
Collapse the table of content
Expand the table of content
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.

TextBox.AcceptsReturn Property


Gets or sets the value that determines whether the text box allows and displays the newline or return characters.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)

public bool AcceptsReturn { get; set; }
<TextBox AcceptsReturn="bool"/>

Property Value

Type: System.Boolean
true if the text box allows newline characters; otherwise, false. The default is false.

Dependency property identifier field: AcceptsReturnProperty.

If you change the AcceptsReturn property to true, text might be displayed differently due to text containing newline characters.

You can enable multi-line text in a TextBox control by using the AcceptsReturn property. Use the HorizontalScrollBarVisibility or VerticalScrollBarVisibility property to enable the horizontal scrollbars or the vertical scrollbars.

The following code snippet shows how you can use the AcceptsReturn property in XAML and code to create a multi-line text box control with scrollbars.

    <TextBox Margin="20,20,0,0" Text="A text box that demonstrates TextWrapping, TextAlignment, MaxLength, and AcceptsReturn" Width="300" Height="50" TextWrapping="Wrap" TextAlignment="Center" MaxLength="500" AcceptsReturn="True" />
    <TextBox Margin="20,20,0,0" Text="A text box that demonstrates HorizontalScrollBarVisibility and VerticalScrollBarVisibility" Width="300" Height="50" AcceptsReturn="True" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" />

public Page()

private void CreateControls()
    //Create stack panel
    StackPanel MyStackPanel = new StackPanel();

    //Create the first text box
    TextBox MyTB1 = new TextBox();
    MyTB1.Width = 300;
    MyTB1.Height = 50;
    MyTB1.Text = "A text box that demonstrates TextWrapping, TextAlignment, MaxLength and AcceptsReturn";
    MyTB1.TextWrapping = TextWrapping.Wrap;
    MyTB1.TextAlignment = TextAlignment.Center;
    MyTB1.MaxLength = 500;
    MyTB1.AcceptsReturn = true;
    MyTB1.Margin = new Thickness(20, 20, 0, 0);

    //Create the second text box
    TextBox MyTB2 = new TextBox();
    MyTB2.Margin = new Thickness(20, 20, 0, 0);
    MyTB2.Text = "A text box that demonstrates HorizontalScrollBarVisibility and VerticalScrollBarVisibility";
    MyTB2.Width = 300;
    MyTB2.Height = 50;
    MyTB2.AcceptsReturn = true;
    MyTB2.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
    MyTB2.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;

    //Add the text boxes to the stack panel
    this.Content = MyStackPanel;


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

© 2017 Microsoft