I am using the WPF WebBrowser control to display a PDF. I want to disable the context menu.
I have already tried the following -
Disable context menu in Internet Explorer control -
In the constructor, added the following -
webBrowser.LoadCompleted +=new LoadCompletedEventHandler(webBrowser_LoadCompleted); // Event Handler public void webBrowser_LoadCompleted(object sender, NavigationEventArgs e ) { webBrowser.ContextMenu = null; var t = webBrowser.Document as System.Windows.Forms.HtmlDocument; // t is always coming as null, even though I can clearly see the pdf in the web browser control. if(t != null) { t.ContextMenuShowing += new System.Windows.Forms.HtmlElementEventHandler(t_ContextMenuShowing); } }Also checked http://social.msdn.microsoft.com/forums/en-US/wpf/thread/7c283faf-16c8-4b4e-a362-f292e3032abb/.
Used the approach to set the registry - HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Internet Explorer\Restrictions\NoBrowserContextMenu to DWORD 1.
When I set the regisrty, the PDF does not get displayed properly.
Also, since I am using PDF to display, I cannot set - in body -
oncontextmenu="return false;"Cannot set
IsWebBrowserContextMenuEnabledas I am using WPF web browser control.