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

25 lines
1.3 KiB
Markdown

---
title: "How to: Make a TextBox Control Read-Only"
ms.date: "03/30/2017"
helpviewer_keywords:
- "read-only TextBox controls [WPF]"
- "TextBox control read-only"
ms.assetid: 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-xaml[TextBox_MiscCode#_ReadOnlyTextBoxXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/TextBox_MiscCode/CSharp/Window1.xaml#_readonlytextboxxaml)]
The <xref:System.Windows.Controls.Primitives.TextBoxBase.IsReadOnly%2A> attribute affects user input only; it does not affect text set in the [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)] 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
- [TextBox Overview](textbox-overview.md)
- [RichTextBox Overview](richtextbox-overview.md)