I want to allow dropping of image files in my application: Users can Drag images from Windows and Drop them into my Window. I have the following code but it seems its not working. I tried both FileDrop
& Bitmap
, both fails
private void Border_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
e.Effects = DragDropEffects.Copy;
} else {
e.Effects = DragDropEffects.None;
}
}
private void Border_Drop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
MessageBox.Show(e.Data.GetData(DataFormats.FileDrop).ToString());
}
else
{
MessageBox.Show("Can only drop images");
}
}
How can I check what formats the user is trying to drop?