Mega Code Archive

 
Categories / C# Tutorial / WPF
 

Listen to text input event for Window

using System; using System.Windows; using System.Windows.Input;     public class MainClass : Window     {         [STAThread]         public static void Main()         {             Application app = new Application();             app.Run(new MainClass());         }         protected override void OnTextInput(TextCompositionEventArgs args)         {             base.OnTextInput(args);             if (args.Text == "\b" && Title.Length > 0)                 Title = Title.Substring(0, Title.Length - 1);         }     }