3

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?

Steffen Winkler
  • 2,805
  • 2
  • 35
  • 58

1 Answers1

3

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

Community
  • 1
  • 1
Mike
  • 73
  • 1
  • 9
  • sorry that was a typo. It also doesn't matter at all. The control behaves exactly the same. As for the tutorial: The DragEnter event is not called either on the WebBrowser control. – Steffen Winkler Mar 20 '14 at 16:59
  • I found a question with a similar topic [here](http://stackoverflow.com/questions/3266045/how-to-disable-drop-on-wpf-webbrowser-control). Maybe you can try this. I also played around with the webbrowser Control and it seems that no Drag event is fired at all. Like the first answer mentions. – Mike Mar 20 '14 at 17:46
  • well, damn. That's probably not gonna work me in my production code. I'm using XWT (a cross-platform GUI toolkit for mono), I don't think I'm able to set that property in there...thanks anyway :). I'd suggest editing your answer to match your comment and I'll mark it as the answer, since the comment does solve the problem in the scope of my question. – Steffen Winkler Mar 20 '14 at 20:42