WPF:如何使自定义控件上的 KeyBinding 在没有焦点的情况下工作
我有两个自定义控件。第一个由文本框和弹出/下拉菜单组成。另一种由扩展器和扩展器内的一些内容组成。
大多数时候,我会在第一个控件的弹出窗口中显示第二个控件。
第二个控件应该有一个用于切换扩展器的热键。
如何在第二个控件中进行键绑定,使其即使焦点位于第一个控件的文本框内也能工作?
I have two custom controls. The first one consists of a textbox and a popup/dropdown. The other consist of a expander and some content inside the expander.
Most of the time, I will display the second control inside the popup of the first.
The second control should have a hotkey for toggling the expander.
How can I make a keybinding in the second control in such a way that it will work even if the focus is inside the textbox of the first control?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为焦点对于 KeyBindings 的工作始终是必不可少的...您是否尝试将 KeyBinding 的 CommandTarget 设置为您的 Expander 控件?
像下面这样...
让我知道这是否有帮助。
I dont think Focus is always essential for KeyBindings to work... did u try setting the CommandTarget of the KeyBinding to your Expander control?
Something like below...
Let me know if this helps.