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

4

1 回答 1

0

您可以找到它作为 e.Source 属性。尝试将其转换为“TextBox”,如果成功,您可以检查“myTextBox”的 Name 属性。

[评论后编辑]

如果 TextBox 在 UserControl 内,则可以使用事件的 OriginalSource 属性。

于 2009-12-01T09:33:57.567 回答