Posts

Showing posts with the label Attached Property WPF TextBox clears Text Escape ESC key MVVM

[Attached Property] WPF TextBox clears Text when user presses Escape key

To add the behavior to the WPF TextBox, use the following XAML. < Window  x : Class ="WPF.MainWindow"            xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"          xmlns : x ="http://schemas.microsoft.com/winfx/2006/xaml"            Title ="WPF TextBox MVVM DataBinding Example"  Height ="500"  Width ="500"          xmlns : Behaviors ="clr-namespace:Behaviors">      < Grid >          < TextBox  Behaviors : TextBoxBehavior.EscapeClearsText ="True" />      > > using  System.Windows; using  System.Windows.Controls; using  System.Windows.Input; namespace   Behaviors {      public   class   TextBoxBeha...