Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-make-a-textbox-control-read-only.md
T
Andy (Steve) De George be103da07e Replace various WPF include files with content (#1335)
* net-current-v30plus-md.md

* net-current-v40plus-md.md

* tla2sharptla-ui-md.md

* tla2sharptla-uiautomation-md.md

* tla2sharptla-winclient-md.md

* tla2sharptla-xaml-md.md

* tlasharptla-ui-md.md

* tlasharptla-uiautomation-md.md

* tlasharptla-winclient-md.md

* tlasharptla-xaml-md.md

* fix warnings
2022-03-16 12:14:11 -04:00

1.3 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Make a TextBox Control Read-Only 03/30/2017
read-only TextBox controls [WPF]
TextBox control read-only
e707ec59-8b22-473e-b77c-3060a237517a

How to: Make a TextBox Control Read-Only

This example shows how to configure a xref:System.Windows.Controls.TextBox control to not allow user input or modification.

Example

To prevent users from modifying the contents of a xref:System.Windows.Controls.TextBox control, set the xref:System.Windows.Controls.Primitives.TextBoxBase.IsReadOnly%2A attribute to true.

[!code-xamlTextBox_MiscCode#_ReadOnlyTextBoxXAML]

The xref:System.Windows.Controls.Primitives.TextBoxBase.IsReadOnly%2A attribute affects user input only; it does not affect text set in the Extensible Application Markup Language (XAML) description of a xref:System.Windows.Controls.TextBox control, or text set programmatically through the xref:System.Windows.Controls.TextBox.Text%2A property.

The default value of xref:System.Windows.Controls.Primitives.TextBoxBase.IsReadOnly%2A is false.

See also