How can I Disable DragDrop Option of WebbrowserControl in Wpf? I searched through google found some solutions but nothing is working.
Setting AllowDrop, AllowWebBrowserDrop properties are not working.
How can I Disable DragDrop Option of WebbrowserControl in Wpf? I searched through google found some solutions but nothing is working.
Setting AllowDrop, AllowWebBrowserDrop properties are not working.
As per my understanding, you want to disable to ability to drag and drop a url or document on the WebBrowser control.
First, can you please try this solution.
Alternatively, subscribe to the WebBrower.Navigating event. Your handler will be passed an instance of the NavigatingCancelEventArgs class before navigation to a document or uri. You can then prevent the user from navigating to another uri if needed. I've included an example below. In the example the browser only navigates to uri within a certain domain.
<WebBrowser Source="https://stackoverflow.com/" Navigating="WebBrowser_Navigating"></WebBrowser>
private void WebBrowser_Navigating(object sender, NavigatingCancelEventArgs e)
{
// Allow navigation to URI in a certain domain e.g http://stackoverflow.com
if (e.Uri.GetLeftPart(UriPartial.Authority) != "http://stackoverflow.com")
{
e.Cancel = true; // Cancel the event
}
}