views:

224

answers:

1

After having started a Drag & Drop operation by DragDrop.DoDragDrop(...) no more MouseMove Events are fired. I even tried

AddHandler(Window.MouseMoveEvent, new MouseEventHandler(myControl_MouseMove), true); 

where the last parameter means I even opt in for handled events. No chance, seems like the MouseMove Event is never fired at all! Any way to still get MouseMove Events while using Drag & Drop? I'd like to Drag & Drop a control, while dragging this control it shall follow the mouse pointer. Any idea how to do this in this case?

+2  A: 

You need to handle the DragOver event.

EDIT: Try handling the GiveFeedback event on the control that you called DoDragDrop on; that might do what you're looking for.

SLaks
thanks for your reply, so I would have to add dragover to all controls in my window and let them point to one single event handler that moves my control?
stefan.at.wpf
I guess so. (I've never done this myself)
SLaks
I finally used the WinApi to get the cursor position, but using dragover is also used sometimes. See http://blogs.msdn.com/b/jaimer/archive/2007/07/12/drag-drop-in-wpf-explained-end-to-end.aspx.
stefan.at.wpf
I used Snoop to help me see that my code was firing the DragOver event and not the MouseMove event. See: http://blois.us/Snoop/
Zamboni
The problem is that DragOver only fires when you enter the bounds of a control that has AllowDrop set to True. It doesn't re-fire as the mouse moves around inside it. So you can't adjust the visual feedback based on the mouse position. GiveFeedBack only fires on the source, not the one you're hovering over.
Scott Whitlock