我需要帮助在Windows Phone 7应用程序中显示webbrowser中的HTML文件。本地HTML文件 - WebBrowser - Windows phone 7
我在我的wpf-silverlight项目中有一个html文件作为资源。现在,当用户点击我的应用程序中的帮助按钮时,我需要在web浏览器中显示此HTML。
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))
请帮帮忙!
我已经改变了这样的代码,但现在我得到这个错误:无效的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());
}
这里是我的代码和我得到这个eror(无效的URI:端口发出信号以“:”但无法解析)开放的URI =新的URI(@“包:/ /application:AppHelp.html“,UriKind.Absolute); Stream stream = Application.GetResourceStream(uri).Stream; using(StreamReader reader = new StreamReader(stream)) { //导航到HTML文档字符串 this.webBrowser1.NavigateToString(reader.ReadToEnd()); } – Pavan
谢谢,达米安.......真棒 – Pavan
设置您的HTML文件的构建选项为“content”并获取流:Application.GetResourceStream(new Uri(“yourfilename.html”,UriKind.Relative)); –