I'd like to be able to drag and drop a file (e.g. from Desktop or Explorer) right into the main window of a WPF application.
I also want no code behind, i.e. I want to use data binding.
So far I tested the "gong-wpf-dragdrop" which doesn't seem to support drag targets outside the application.
I could drop a file to the main window and the drag and drop events fired - but the data was empty (dragged a non-empty text file).
EDIT: gong-wpf-dragdrop works (after a small fix) and the problem also occurred when using code behind.
So the complete solution was to use gong wpf (github) and the solution presented by Omribitan.
have you tried GetFileDropList method? you can retreive it from the e.Data in the Drop event.
Something like:
string filename = (string)((DataObject)e.Data).GetFileDropList()[0];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With