Local HTML File - WebBrowser - Windows phone 7

只愿长相守 提交于 2019-12-01 06:49:13

问题


I need help in displaying HTML File in webbrowser in Windows phone 7 app.

I've an html file in my wpf-silverlight project as resource. Now When the user click on Help button in my App, i need to display this HTML in webbrowser.

Here is the code, which is giving me an error -

webBrowser1.Navigate(new Uri("AppHelp.html",UriKind.Relative))

But, if i use this code, It's loading fine

webBrowser1.Navigate(new Uri("http://mywebsite.com/AppHelp.html",UriKind.Relative))

Please help!

I've change code like this now, but now i'm getting this error:Invalid URI: A Port is signaled with ':' but could not be parsed.

   Uri uri = new Uri(@"pack://application:AppHelp.html", UriKind.Absolute);
    Stream stream = Application.GetResourceStream(uri).Stream;
    using (StreamReader reader = new StreamReader(stream))
    {
        // Navigate to HTML document string
        this.webBrowser1.NavigateToString(reader.ReadToEnd());
    }

回答1:


You can use method NavigatedToString of WebBrowse object by getting content of html file and put it as parameter of this method.

http://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser.navigatetostring.aspx

samples at: http://blogs.msdn.com/b/mikeormond/archive/2010/12/16/displaying-html-content-in-windows-phone-7.aspx




回答2:


You can try this,

http://www.c-sharpcorner.com/uploadfile/raj1979/how-to-embed-html-file-in-windows-phone-7/

and for with image in html

you can this, Use local images in Webbrowser control

using IsolatedStorages



来源:https://stackoverflow.com/questions/8044528/local-html-file-webbrowser-windows-phone-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!