0

I've a UserControl which contains a TextBox called myTextBox. This UserControl is placed in a MainWindow.xaml where I'm trying to catch the "UIElement.PreviewKeyUp".

Now when debugging, I can see the "UserControl" as sender, not the TextBox. How can I check if the KeyEventArgs e (especially e.Key) were sent from the TextBox called myTextBox?

Thanks for any help.

Cheers

Joseph jun. Melettukunnel
  • 6,267
  • 20
  • 69
  • 90

1 Answers1

0

You can find it as the e.Source property. Try to cast it to 'TextBox', and if it succeeds, you can check the Name property for 'myTextBox'.

[edited after comment]

If the TextBox is inside a UserControl, you can use the OriginalSource property of the event.

Eric Minkes
  • 1,421
  • 2
  • 10
  • 12
  • Thanks Eric. Unfortunately this doesn't work.. the debugger shows me in the e.Source the UserControl. Please have a look at this screenshot: http://img22.imageshack.us/img22/7873/scrntextboxevent.png – Joseph jun. Melettukunnel Dec 01 '09 at 10:24