Drag and drop files into WPF?

This is basically what you want to do. Private void ImagePanel_Drop(object sender, DragEventArgs e) { if (e.Data. GetDataPresent(DataFormats.

FileDrop)) { // Note that you can have more than one file. String files = (string)e.Data. GetData(DataFormats.

FileDrop); // Assuming you have one file that you care about, pass it off to whatever // handling code you have defined. HandleFileOpen(files0); } }.

Fascinating. I guess I failed to post fully-working, copy-and-paste-ready sample code. – Cody Gray Apr 14 at 13:33 awesome works a charm, just swapped "HandleFileOpen(files0);" to "foreach(string file in files) { Openfile(file); }" - Thanks :) – Eamonn McEvoy Apr 14 at 13:36.

The image file is contained in the e parameter, which is an instance of the DragEventArgs class. (The sender parameter contains a reference to the object that raised the event. ) Specifically, check the e.

Data member; as the documentation explains, this returns a reference to the data object (IDataObject) that contains the data from the drag event. The IDataObject interface provides a number of methods for retrieving the data object that you're after. You'll probably want to start by calling the GetFormats method in order to find out the format of the data that you're working with.(For example, is it an actual image or simply the path to an image file?) Then, once you've identified the format of the file being dragged in, you'll call one of the specific overloads of the GetData method to actually retrieve the data object in a particular format.

Yes, this answer is more complete, but I find that most of the time people asking questions don't really want to do the reading. I have TONS of ignored answers to prove it. – A.R.Apr 14 at 14:01.

I think this is similar to Image drag and drop in wpf application. Have a look at the answers.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions