How can I disable dropping of files on a System.Windows.Controls.WebBrowser? From the documentation it would seem that this behaviour should be disabled by default as it is inherited from the UIElement.AllowDrop Property.
However dy default I can drag and drop files on to a WebBrowser control. Further to this it seems I can’t disable this supposedly none-default behaviour. For example if I explicitly set the value of the property to false in XAML
<WebBrowser Name="webBrowser1" AllowDrop="False" />
..and/or in code-behind, i.e.
webBrowser1.AllowDrop = false;
Then I can still drag and drop files onto the control. How can I disable this behaviour and remove the security risk it creates?
Ok after hours and hours of playing with this I have come up with one solution that works. Because I am using the standard WPF webbrowser I know I can also use the “Extended Event Attributes” that Microsoft introduced for Internet Explorer.
The event I am using to disable dropping files onto the control is ondragover. Essentially I just cancel the event whenever it happens like so.
This is not really ideal – but what is good about this technique is that it allows for a whole host of other properties to be set that are not available directly from managed code. For the scrollbar state, which is not exposed in managed code, can be set this way.