The drag/drop associated events in WPF (
DragEnter,
DragOver,
Drop, etc.) are fully fired and handled beautifully for "FileDrop" data originating from Windows explorer, as well as browsers (at least Firefox). However, they seem to be completely inert to "FileDrop" data drags originating from certain other applications.
(A number of solutions I've found point to issues with unequal UIPI levels, but these solutions seem to be unrelated as none of the applications have administrator privileges, nor does mine, nor does VS.)
Moreover those same drag/drop operations from the same applications fire perfectly if the target app is a WinForm app instead of WPF, so this is clearly a WPF issue. I can't redo my application as a WinForms app (nor do I wish to).
What I have tried:
Searching the net far and wide points to using ole32.dll
public static extern int RegisterDragDrop(IntPtr hwnd, IDropTarget pDropTarget);
which I have done my best to implement.
That is, I've created a class implementing IDropTarget:
internal class DropClass : IDropTarget ...
with the appropriate events (
DragEnter, etc.)
Then I register my WPF window through
RegisterDragDrop, immediately after
InitializeComponent(), and I use that created class as the target.
I believe I've done it correctly, and yet none of the events of that class are being fired.
Incidentally certain comments suggested that when calling
RegisterDragDrop the original WPF window setting "AllowDrop" should be set to false, so that has been tried as well.
My fallback hack solution right now is to use a transparent
WindowsFormsHost over the WPF window to capture the OLE drag drop events, since only a WinForm seems to grab them. Much much less than ideal, of course. But I can't believe it's not possible to conduct filedrop operations from any application into WPF