本地HTML文件 - WebBrowser - Windows phone 7

3
我需要帮助在Windows Phone 7应用程序中显示HTML文件。 我在我的WPF-Silverlight项目中有一个HTML文件作为资源。 现在当用户点击我的应用程序中的“帮助”按钮时,我需要在WebBrowser中显示此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());
    }
2个回答

1

1

这是我的代码,我遇到了这个错误(无效的URI:使用“:”标记端口,但无法解析。)Uri uri = new Uri(@“pack://application:AppHelp.html”,UriKind.Absolute); Stream stream = Application.GetResourceStream(uri).Stream; using(StreamReader reader = new StreamReader(stream)) { // 导航到HTML文档字符串 this.webBrowser1.NavigateToString(reader.ReadToEnd()); } - Pavan
将您的HTML文件的构建选项设置为“content”,并获取流:Application.GetResourceStream(new Uri("yourfilename.html", UriKind.Relative)); - Damian Jarosch
1
NavigateToString对图片的处理不太友好。 - Esa
非常感谢!我也遇到了URI的问题,但是已经解决了。 :) - ameya rote

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接