IsReadOnly Property

TextBox.IsReadOnly Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets the value that determines if the user can change the text in the text box.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

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

Property Value

Type: System.Boolean
true if the text box is read-only; otherwise, false. The default is false.

Dependency property identifier field: IsReadOnlyProperty.

If the text box is read-only, no user input or edits are allowed, but programmatic changes can be made. The user can still select text, and the cursor still appears. The KeyUp and KeyDown events are marked as handled.

The following code snippet displays a read-only text box.


<TextBlock Margin="20,20,0,0" Text="Read Only TextBox"/>

<TextBox x:Name="ReadOnlyTB"  IsReadOnly="True" HorizontalAlignment="Left" Margin="20,5,0,0" Height="70" Width="200" />


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2016 Microsoft