【问题标题】:Opening docx file in Windows Phone 8 webbrowser control在 Windows Phone 8 webbrowser 控件中打开 docx 文件
【发布时间】:2014-01-27 20:21:59
【问题描述】:

我在 windows phone 8 的 webbrowser 控件中加载一个 URL。当我单击可从站点下载的 docx 文件时,它没有被下载或打开。它只是继续加载。无论如何在webbrowser控件中打开docx文件或下载docx文件并通过WP8的IE10浏览器打开?

【问题讨论】:

    标签: c# windows-phone-8


    【解决方案1】:

    您需要附加到 WebBrowser (reference) 的 Navigating 事件。在这种情况下,您需要查找要处理的 URL,然后直接启动它们,然后取消导航。像这个未经测试的代码。

    void web_Navigating(object sender, NavigatingEventArgs e) {
       string url = e.Uri.ToString();
       if (url.EndsWith("docx")) {
          Launcher.LaunchUriAsync(url);
          e.Cancel = true;
          return;
       }
     } 
    

    【讨论】:

      【解决方案2】:

      您可以通过像这样传递 url 轻松打开它

      await Launcher.LaunchUriAsync(new Uri("http://www.abundantcode.com/mydoc.docx"));
      

      【讨论】:

      • 我已经通过 webbrowser 控件加载网站。在浏览页面时,我们可能会遇到需要下载或打开的 docx 文件。在那种情况下,我需要解决方案。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-11
      • 2012-11-12
      • 1970-01-01
      • 1970-01-01
      • 2012-11-16
      相关资源
      最近更新 更多