5

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.

4

1 回答 1

8

你试过GetFileDropList方法吗?您可以从Drop事件中的 e.Data 中检索它。

就像是:

string filename = (string)((DataObject)e.Data).GetFileDropList()[0];
于 2013-10-14T08:22:22.433 回答