* 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
1.8 KiB
title, description, ms.date, ms.custom, dev_langs, helpviewer_keywords, ms.assetid
| title | description | ms.date | ms.custom | dev_langs | helpviewer_keywords | ms.assetid | ||||
|---|---|---|---|---|---|---|---|---|---|---|
| How to: Set the Text Content of a TextBox Control | Learn how to use the Text property to set the initial text contents of a Windows Presentation Foundation TextBox control. | 03/30/2017 | devdivchpfy22 |
|
|
bcd25fc7-a52f-4453-b802-2c8d2b335ab8 |
How to: Set the Text Content of a TextBox Control
This example shows how to use the xref:System.Windows.Controls.TextBox.Text%2A property to set the initial text contents of a xref:System.Windows.Controls.TextBox control.
Note
Although the Extensible Application Markup Language (XAML) version of the example could use the
<TextBox.Text>tags around the text of each button's xref:System.Windows.Controls.TextBox content, it is not necessary because the xref:System.Windows.Controls.TextBox applies the xref:System.Windows.Markup.ContentPropertyAttribute attribute to the xref:System.Windows.Controls.TextBox.Text%2A property. For more information, see XAML in WPF.
Use the Text property to set the text contents
[!code-xamlTextBox_MiscCode#_TextBoxSetTextXAML]
Set the Text Content of a TextBox Control
[!code-csharpTextBox_MiscCode#_TextBoxSetText] [!code-vbTextBox_MiscCode#_TextBoxSetText]