如何获取将触发路由命令的输入绑定?
我有一个菜单项,它分配了一个命令(MyCommands.Indent)和两个文本区域,两个文本区域都有一个触发 MyCommands.Indent 的输入绑定。 困难的部分是输入绑定具有不同的手势,我希望这些手势在 MenuItem 中更改。
所以我的问题是:如何获取将触发此路由命令的输入绑定?
I have a menuitem which have a command assigned to it (MyCommands.Indent) and two text areas, both having an input binding triggering MyCommands.Indent. The hard part is that input bindings have different gestures and I would like these gestures to change in MenuItem.
So my question is: How do I get input bindings which would trigger this routed command?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能看到具体执行您所要求的操作的唯一方法是探索可视化树以查找带有 InputBindings 到 RoutedCommand 的项目...这不是一个很好的想法!
但可能有更好的方法:您不使用 InputGestures 属性在 RoutedCommand 中定义快捷方式吗? 这样你就不再需要InputBindings了......
The only way I can see to do specifically what you're asking, is to explore the visual tree to find items with InputBindings to your RoutedCommand... not a very nice thought !
But there might be a better approach : what don't you just define the shortcut in the RoutedCommand, using the InputGestures property ? That way you won't be needing the InputBindings anymore...