Dragging happens from “source” to “target”. When the source calls DoDragDrop() with allowedEffects as DragDropEffects.Copy, then I’m able to cancel the drop by setting Effects = DragDropEffects.None at the target (in DragOver event).
But the same situation fails when I set my allowedEffects as DragDropEffects.Move.
To reproduce the situation, download the sample from http://jaimersamples.members.winisp.net/samples/dragdrop/drag.zip
Change line.. (to DragDropEffects.Move)
DragDrop.DoDragDrop(this.DragSource, data, DragDropEffects.Copy);
Add line..
void Window1_DragOver(object sender, DragEventArgs args)
{
args.Effects = DragDropEffects.None;
And also comment out the entire, DragSource_GiveFeedback..
void DragSource_GiveFeedback(object sender, GiveFeedbackEventArgs e)
{
//System.Diagnostics.Debug.WriteLine("DragSource_GiveFeedback " + e.Effects.ToString());
Is there some kind of bug in the framework, or am I just not able to see something obvious?
After going over your comments and your code again, with some effort I was able to understand and reproduce the problem you are talking about.
What you’re missing is the line:
In your
Window1_DragOverevent. Add that and it will work the same for bothDragDropEffects.MoveandDragDropEffects.Copy.Why it worked for
DragDropEffects.Copywithout settinge.Handledin the first place is anyone’s guess. Undocumented conditions lead to undocumented behaviour.I’m going to very strongly recommend that next time you post a code sample containing the minimum possible code to reproduce the problem. I apologize for the original confusion, but nevertheless it was very hard to figure out what was going on in this one.