简体   繁体   中英

Drag&Drop with WPF WebBrowser control - Drop event not firing

I'm currently in need to capture the Drop event of the WPF WebBrowser control but for some reason it's not firing. If I drag a .pdf file into the control it's being displayed but the Drop event isn't firing.

Small sample: Create a new WPF project, add this inside the XAML code of the MainWindow.xaml between the Grid tags:

<WebBrowser Name="test" />

And change the MainWindow.xaml.cs so it looks like this:

 public MainWindow()
        {
            InitializeComponent();
            test.AllowDrop = true;
            test.Drop += test_Drop;
        }

        void test_Drop(object sender, DragEventArgs e)
        {
            MessageBox.Show("Hi");
        }

The messagebox will not be displayed when you drop a PDF file inside the WebBrowser control. What am I doing wrong?

You should try test.AllowDrop = true; . Take a look at this Tutorial

Edit:

After a few tries and a little research i found out that no Drag event will be fired at all. But maybe this question helps you here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM