Wpf dragdrop, how to visually reject a drop while dragging and dropping?

While dragging and dropping in Wpf, how can I move the mouse cursor (or perhaps use adorner) to indicate that droptargetit will not accept the dragged item?

I tried to set e.Effects = DragDropEffects.Noneduring the event DragEnter, but this does not work, and I suspect that I misunderstood what this function should be used for. I tried to use the event GiveFeedback, but I don’t see how it droptargetcan affect it.

Are there any tutorials that cover deviation droptargetin Wpf?

+5
source share
3 answers

DragDropEffects DragEnter . DragEnter . AllowDrop ?

WPF ( MSDN), , ...

  • DoDragDrop .

    DoDragDrop :     * ,     * allowedEffects, , ( / )

    DataObject.

  • , , GiveFeedback. GiveFeedback, , .
  • AllowDrop, True, . AllowDrop "" Form_Load.
  • , DragEnter . GetDataPresent , Effect .
  • , DragDrop . DragDrop DataObject .
+6

, GiveFeedback. , . (e.UseDefaultCursors = true) " ".

0

You did not say if you use it DragOverexactly. Perhaps you install e.Effect = DragDropEffects.All;in this even, and it will run several times after entering the target control instead DragEnter, which will only run once.

    private void arbol_DragOver(object sender, DragEventArgs e)
    {
        if (some_reason)
            e.Effect = DragDropEffects.None;
        else
            e.Effect = DragDropEffects.All;
    }

If you have not used this event or changed it e.Effectinternally, then it is difficult to say. Code is required.

0
source

All Articles