简体   繁体   中英

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 . 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.

So when an item is dragged over the child element, the event handlers of the parent elt is used instead of the child. I 've child to use child.PreviewDragEnter .. instead of DragEnter but it does not work.

Strange enough, for MouseEvent like mouseEnter or mouseLeave handlers of both Parent and child work.

Can anyone help me with that. How can the drageventhandler of the Child elt be used instead.

Thank you very much.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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