Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-make-a-textbox-control-read-only.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07: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 [!INCLUDETLA#tla_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