Drag the file into the application window using WPF and data binding

I would like to be able to drag and drop a file (for example, from the desktop or explorer) directly into the main window of the WPF application.

I also don't need the code, i.e. I want to use data binding.

So far I have tested "gong-wpf-dragdrop", which does not seem to support drag and drop targets outside the application.

I could delete the file in the main window, and the drag events - but the data was empty (dragged a non-empty text file).

EDIT: gong-wpf-dragdrop works (after a small fix), and the problem also occurs when using the code.

So the complete solution was to use gong wpf ( github ) and the solution provided by Omribitan.

+4
source share
1 answer

Have you tried the GetFileDropList method ? You can get it from e.Data in the Drop event .

Sort of:

string filename = (string)((DataObject)e.Data).GetFileDropList()[0];
+8
source

All Articles