开发者

WPF: How to get the event when one FrameworkElement comes in contact with other FrameworkElement

I am developing a small application with images and trash box icon on righ开发者_高级运维t hand bottom.

I have multiple images floating in the main window, and using mouse I can move image from one corner to other corner of window, left, right, top and bottom.

I can't figure out how do I catch an event when a image touches and panel (with trash box image), in the right hand corner.

Does anybody knows which event or handler to listen? This is not a drag and drop case since my images are floating so no point using drag and drop.

Thank you


Per this thread (MSDN), you could listen to an event fired when your image moves, and get Rects representing the trash box and the image, then use the IntersectsWith() method to detect if they are "touching".

Other than that, there are the UIElement events DragEnter, DragOver, and Drop (as well as their Preview___ counterparts) which might fit the bill. However, those are part of drag-and-drop. I'm not convinced that drag-and-drop is not appropriate in this situation. It sounds like drag and drop to me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜