Hi. I have a <WebBrowser> control in the WPF app, and it should either display a local PDF file or render a webpage URL inside.
There is a problem with both requirements.
1) Local PDF files: When I navigate to the local PDF file location, it prompts me to download the file, rather than display it on the UI.
2) Webpage URL: When I set the source to a URL, e.g. http://www.microsoft.com, it uses Internet Explorer and gets hiccups with all scripts. Error message: "Script Error | An error has occurred in the script on this page. Do you want to continue running scripts on this page?"
The page gets displayed fine, however. It just gives me those Script Error Yes/No messageboxes.
Is there a way I can fix that? If not, any alternatives?
Thanks.
Code:
<WebBrowser x:Name="webBrowser" />
if (Uri.IsWellFormedUriString(value, UriKind.Absolute)) // e.g. http://www.microsoft.com
{
webBrowser.Source = new Uri(HelpFilesCombobox.SelectedValue.ToString());
}
else // e.g. C:\MyFile.pdf
{
webBrowser.Navigate("file:///" + HelpFilesCombobox.SelectedValue.ToString());
}