if( TextBoxInFocus != null ) { KeyEventArgs k = new KeyEventArgs( Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, System.Environment.ProcessorCount, Key.D0 ); //KeyEventArgs k = new KeyEventArgs( Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.D0 ); k.RoutedEvent = UIElement.KeyDownEvent; TextBoxInFocus.RaiseEvent( k ); k.RoutedEvent = UIElement.KeyUpEvent; TextBoxInFocus.RaiseEvent( k ); }