简体   繁体   English

如何忽略父级的事件处理程序,以便在WPF中使用子级事件处理程序(对于DragEvent)

[英]How to ignore Parent's event handler in order to use Child event handler (for DragEvent) in WPF

I am having a problem in using the DragEventHandler . 我在使用DragEventHandler时遇到问题。 The scenario is that: A parent element which has its own DragEventHandler s (in this case Grid) contains child element (Panel) which also has its own DragEventHandler s. 场景是:具有其自己的DragEventHandler的父元素(在本例中为Grid)包含子元素(Panel),该子元素也具有其自己的DragEventHandler

So when an item is dragged over the child element, the event handlers of the parent elt is used instead of the child. 因此,当将项目拖到子元素上时,将使用父elt的事件处理程序代替子元素。 I 've child to use child.PreviewDragEnter .. instead of DragEnter but it does not work. 我已经使用child.PreviewDragEnter ..代替DragEnter但是它不起作用。

Strange enough, for MouseEvent like mouseEnter or mouseLeave handlers of both Parent and child work. 奇怪的是,对于MouseEvent如ParentEnter和child的mouseEnter或mouseLeave处理程序。

Can anyone help me with that. 谁能帮助我。 How can the drageventhandler of the Child elt be used instead. 如何代替使用child elt的drageventhandler。

Thank you very much. 非常感谢你。

没有您正在使用的语言和库的更多详细信息就不能说太多。但是我见过的一个常见技巧是,如果您希望将父元素分开,请确保在父元素之前实例化子元素的绑定。从父母那里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM