* 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
3.1 KiB
title, description, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | description | ms.date | dev_langs | helpviewer_keywords | ms.assetid | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| How to: Detect When Text in a TextBox Has Changed | Learn how to use the TextChanged event to run a method whenever the text in a TextBox control changes in a Windows Presentation Foundation application. | 03/30/2017 |
|
|
1c39ee14-e37f-49fb-a0d1-a9824ca13584 |
How to: Detect When Text in a TextBox Has Changed
This example shows one way to use the xref:System.Windows.Controls.Primitives.TextBoxBase.TextChanged event to execute a method whenever the text in a xref:System.Windows.Controls.TextBox control has changed.
In the code-behind class for the [!INCLUDETLA2#tla_xaml] that contains the xref:System.Windows.Controls.TextBox control that you want to monitor for changes, insert a method to call whenever the xref:System.Windows.Controls.Primitives.TextBoxBase.TextChanged event fires. This method must have a signature that matches what is expected by the xref:System.Windows.Controls.TextChangedEventHandler delegate.
The event handler is called whenever the contents of the xref:System.Windows.Controls.TextBox control are changed, either by a user or programmatically.
Note
This event fires when the xref:System.Windows.Controls.TextBox control is created and initially populated with text.
Example
In the [!INCLUDETLA#tla_xaml] that defines your xref:System.Windows.Controls.TextBox control, specify the xref:System.Windows.Controls.Primitives.TextBoxBase.TextChanged attribute with a value that matches the event handler method name.
[!code-xamlTextBox_MiscCode#_TextChangedXAML]
Example
In the code-behind class for the [!INCLUDETLA2#tla_xaml] that contains the xref:System.Windows.Controls.TextBox control that you want to monitor for changes, insert a method to call whenever the xref:System.Windows.Controls.Primitives.TextBoxBase.TextChanged event fires. This method must have a signature that matches what is expected by the xref:System.Windows.Controls.TextChangedEventHandler delegate.
[!code-csharpTextBox_MiscCode#_TextChangedEventHandler] [!code-vbTextBox_MiscCode#_TextChangedEventHandler]
The event handler is called whenever the contents of the xref:System.Windows.Controls.TextBox control are changed, either by a user or programmatically.
Note
This event fires when the xref:System.Windows.Controls.TextBox control is created and initially populated with text.
Comments