本地HTML文件-WebBrowser-Windows Phone 7 [英] Local HTML File - WebBrowser - Windows phone 7

查看:58
本文介绍了本地HTML文件-WebBrowser-Windows Phone 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows Phone 7应用程序的Webbrowser中显示HTML文件时,我需要帮助。

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

我在wpf-silverlight项目中有一个html文件作为资源。现在,当用户单击我的应用程序中的帮助按钮时,我需要在Web浏览器中显示此HTML。

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))

请帮助!

我现在已经更改了这样的代码,但是现在我收到此错误:无效的URI:端口以':'表示,但无法解析。

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());
    }


推荐答案

您可以使用NavigatedToString方法通过获取html文件的内容并将其作为此方法的参数来WebBrowse对象。

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

示例位于:
http://blogs.msdn.com/b/mikeormond/archive/2010/12/16/displaying-html-content -in-windows-phone-7.aspx

这篇关于本地HTML文件-WebBrowser-Windows Phone 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆