Drag and drop image in web browser in WPF

I have a window that allows drop, and my Drop event handler works great for images being dragged from Windows Explorer. But dragging and dropping images from a web browser has some features.

In Firefox, I only get .bmp files with random names. Images from IE 8 (others have not tested) display only an inaccurate mouse cursor. I assume this is because IE has a security request when dragging and dropping images into Windows Explorer.

Does anyone come across a solution, possibly a browser agent, to drag and drop images from a web browser and into a WPF window?

Here's the current event handler:

private void Window_Drop(object sender, DragEventArgs e)
    {
        if (e.Data.GetDataPresent(DataFormats.FileDrop))
        {
            string[] droppedFilePaths = e.Data.GetData(DataFormats.FileDrop, true) as string[];

            foreach (string droppedFilePath in droppedFilePaths)
            {
                Debug.WriteLine(droppedFilePath);
            }
        }
    }
+3
1

IE8. , PreviewDragEnter PreviewDragOver , , " " :

    private void Window_PreviewDragEnterAndOver ( object sender , DragEventArgs e ) {
        e.Effects = DragDropEffects.Link;
        e.Handled = true;
    }
0

Source: https://habr.com/ru/post/1760201/


All Articles