从弹出窗口监听路由事件/命令
我有一个动态创建弹出窗口的控件。
弹出窗口包含触发路由事件/命令的控件,我想在原始控件中对其做出反应。原始控件被设置为弹出窗口的放置目标。
您希望原始控件接收冒泡事件吗?我知道它位于不同的视觉树中,但我想知道它们是否会提供给展示位置目标。从我的代码看来不是。
谁能建议一种方法来处理这种情况?响应不同视觉树中的事件。我想知道是否可以编写一些控件,将其置于弹出窗口的根部并充当原始视觉树的“桥梁”?
非常感谢,
I have a control that dynamically creates a popup.
The popup contains controls that fire routed events / commands, which I want to react to in the original control. The original control is set as the placement target of the popup.
Would you expect the original control to receive bubbled events? I know it's in a different visual tree, but I wondered whether they would be offered to the placement target. From my code it would appear not.
Can anyone suggest a way to handle this situation? Responding to events in a different visual tree. I was wondering if there was some control I could write that would sit in the root of the popup and act as a "bridge" into the originating visual tree?
Many thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过将 CommandBinding 添加到弹出窗口的 CommandBindings 集合而不是控件的 CommandBinding 集合中,设法解决了这个问题。
当我在创建弹出窗口时在代码中执行此操作时,我可以在控件中指定回调,即使绑定位于弹出窗口中也是如此。
I have managed to get around this by adding my CommandBinding to the popup's CommandBindings collection instead of my control's.
As I do this in code at the point of the popup's creation, I can specify callbacks in my control, even though the binding is in the popup.