当窗口包含文本框的previewkeydown事件时如何处理window keydown事件?
我的应用程序有自定义图像控件,按钮和自定义文本框。我在属于图像的窗口keydown事件中实现了一些按键操作,在文本框previewkeydown事件中实现了一些按键操作。当焦点位于图像或按钮上时,窗口的按键操作效果很好。当焦点在文本框上时,两个按键操作的组合效果不佳。例如,当焦点在文本框上时,如果我按 ctrl + 向上箭头,首先它会触发文本框和窗口 keydown 的 keydown 事件e.key 包含 ctrl.second 文本框的 keydown 事件被触发,但 windows keydown 事件没有被触发,为什么..?
My application have custom image control,button and a custom textbox.I implemented some key operations in window keydown event belonging to image and some key operations in textbox previewkeydown event.When the focus is on image or button,key operations of the window works well.When the focus is on the textbox,combination of two key operations doesn't work well.For example,when the focus is on textbox,if I pressed ctrl + up arrow,first it fires the keydown event of both textbox and window keydown event where e.key contain ctrl.second textbox's keydown event is fired but windows keydown event is not fired why..?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
输入绑定可以帮助您吗?
请参阅:http://www.switchonthecode.com/tutorials /wpf-tutorial-command-bindings-and-custom-commands
它在 WPF 中用于键盘输入的方式比 KeyDown 和 KeyUp 事件更多。我现在也有自己的问题,呃。
Might input binding help you out?
See: http://www.switchonthecode.com/tutorials/wpf-tutorial-command-bindings-and-custom-commands
Its what's used for keyboard input in WPF way more than the KeyDown and KeyUp events. I'm having my own issues with those right now, ugh.