20

My WPF application inhibits the Drop of files from Windows Explorer, showing a Stop-sign cursor.

I've tried setting the AllowDrop property (that of the UIElement ancestor) to true on the main window and contained controls, but no luck at all, no drag-drop events are fired.

Any ideas or suggestions to find the cause?

Néstor Sánchez A.
  • 3,848
  • 10
  • 44
  • 68

3 Answers3

25

Solved!

The problem was that executing my app thru VisualStudio (run/debug) prevented the interop with Windows' drag & drop mechanism. Running the App as stand-alone makes it work, but cannot debug interactively.

This answer helped a lot: Visual Studio 2010 WPF Project ran in debug or relase will not allow drag and drop to any control

Community
  • 1
  • 1
Néstor Sánchez A.
  • 3,848
  • 10
  • 44
  • 68
19

In my case it was running Visual Studio as Administrator on Windows 10. The UAC prevented the drag/drop. When I ran VS without elevating drag/drop started working in debug mode.

stambikk
  • 1,175
  • 12
  • 23
7

According to this: http://codeinreview.com/136/enabling-drag-and-drop-over-a-grid-in-wpf/ (Which I am happy to report works!)

All you need to do is add a background on the control that has to get the drop. This will enable hit testing and thus make the drop-feature work.

Note: The background can be transparent, you just have to set it.

aliceraunsbaek
  • 625
  • 7
  • 18