Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 Winforms ElementHost 中有一个 WPF 窗口。KeyDown 和 PreviewKeyDown 事件不会为我的窗口上的 Tab 键和箭头键触发。
KeyUp 和 PreviewKeyUp 似乎工作正常,大多数其他键的 PreviewKeyDown 也是如此,例如:AZ,0-9
问题是我的窗口是从 Winforms 应用程序打开的。ElementHost.EnableModelessKeyboardInterop()方法解决了我的问题。
var myWindow = new MyWindow(); ElementHost.EnableModelessKeyboardInterop(myWindow); myWindow.Show();