Rn

Rn

  • NA
  • 1
  • 0

TextBox RaiseEvent KeyDownEvent does not work

Dec 14 2010 3:21 PM
Trying to raiseEvent to textBox - but i don't see the key value in the textBox text. I can see that the textbox event "OnKeyDownEvent" is stopping in breakpoints - but i don't understand why the text of the KeyEventArgs ( Key.D0 ) is not insert into the textbox text.

The code:


 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 );



}

Answers (1)