R – Stop Dragging from a WPF WebBrowser control

browserdrag and dropwebbrowser-controlwpf

I have a WPF application which contains a WebBrowser control.

Currently, the user can select something within the WebBrowser and can copy the content by dragging it out to another application and dropping it there.

I'd like to be able to stop the user doing this. I'd assumed that there would be a "DragStart" event that I could capture and cancel – but I haven't been able to find something so simple.

Is it possible to capture the start of drag event and cancel it?
Is there a better way to achieve this?

Best Answer

You can implement IDocHostUIHandler::FilterDataObject and filter out common clipboard formats

You don't get access the WPF browser's native interface until the document is ready. Not sure if it would work with the WPF browser class. There is also a bug in Windows Forms to prevent you from customizing its implementation of IDocHostUIHandler.

You can try some wrapper class of the webbrowser ActiveX, such as the one described at http://www.codeproject.com/KB/miscctrl/csEXWB.aspx