本地 HTML 文件 - 网络浏览器 - Windows Phone 7
我需要帮助在 Windows Phone 7 应用程序的网络浏览器中显示 HTML 文件。
我的 wpf-silverlight 项目中有一个 html 文件作为资源。现在,当用户单击我的应用程序中的“帮助”按钮时,我需要在网络浏览器中显示此 HTML。
这是代码,它给了我一个错误 -
webBrowser1.Navigate(new Uri("AppHelp.html",UriKind.Relative))
但是,如果我使用这段代码,它加载得很好
webBrowser1.Navigate(new Uri("http://mywebsite.com/AppHelp.html",UriKind.Relative))
请帮忙!
我现在已经更改了这样的代码,但现在我收到此错误:无效的 URI:端口用“:”表示,但无法解析。
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());
}
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());
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过获取 html 文件的内容并将其作为该方法的参数来使用 WebBrowse 对象的 NavigatedToString 方法。
http://msdn.microsoft.com/en -us/library/system.windows.controls.webbrowser.navigatetostring.aspx
示例位于:
http ://blogs.msdn.com/b/mikeormond/archive/2010/12/16/displaying-html-content-in-windows-phone-7.aspx
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
你可以试试这个,
http://www.c-sharpcorner.com/uploadfile/raj1979/how-to-embed-html-file-in-windows-phone-7/
以及对于 html 中的图像,
您可以这样做,
在Webbrowser控件中使用本地图像
使用IsolatedStorages
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