本地 HTML 文件 - 网络浏览器 - Windows Phone 7

发布于 2024-12-14 02:54:58 字数 880 浏览 3 评论 0原文

我需要帮助在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

断爱 2024-12-21 02:54:58

您可以通过获取 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

瞄了个咪的 2024-12-21 02:54:58

你可以试试这个,

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

以及对于 html 中的图像,

您可以这样做,
在Webbrowser控件中使用本地图像

使用IsolatedStorages

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文