12

我正在设计一个 Windows 8 阅读器应用程序,我必须使用一个控件来显示 HTML 内容,这些内容是从一些网站提要中获取的。因为那些 HTML 内容可能包含图像或其他格式的文本,现在我使用 Richtextblock 来显示 HTML 内容,但是解析 HTML 内容需要花费大量时间。

所以我想知道是否有任何控件可以处理除了 WebView 之外的 HTML 内容。

谢谢。

更新:我不能使用 WebView 的原因是我需要实现分页,如下图:

在此处输入图像描述

4

3 回答 3

4

As JP Alioto mentioned you should use the WebView control.

You can use the NavigateToString method to load the HTML. Or use Navigate to request a URI.

There are issues however with using the WebView control, specifically it is rendered differently and is not a standard control, this means things like your app bar or settings pane will not render on top of the WebView, there is a workaround by using the WebViewBrush to "paint" the WebView to standard control such as a rectangle when needed.

于 2012-06-04T18:18:56.540 回答
1

您还可以对要显示的网页进行屏幕截图。但是要对网页进行截图也不是一件容易的事,但我提供了一些特殊的网站来制作它,这些网站是为了截取其他网站而创建的。然后,您可以下载此站点返回的图像并在您的 Windows 8 应用程序中打开并显示它。我向您展示了一些示例,我是如何做到的:

 StorageFolder screens = await Windows.ApplicationModel.Package.Current.InstalledLocation.CreateFolderAsync(@"Screens\" + folderName, CreationCollisionOption.GenerateUniqueName);
 var downloader = new BackgroundDownloader();
 IStorageFile file = await screens.CreateFileAsync(fname, CreationCollisionOption.GenerateUniqueName);
 string my_uri = "http://api.snapito.com/web/e3c351d5994134eb1aea855ce78e296c3292d48a/lc/" + url + "?type=jpeg";
 DownloadOperation download = downloader.CreateDownload(new System.Uri(my_uri), file);
 await download.StartAsync();
于 2013-06-24T14:14:52.830 回答
0

我认为只有两种选择,但都不是很好:

  • 使用 WebView 并使用 CSS 和其他技术转换您的 HTML 以使其看起来原生。使用ScriptNotifyandNavigationStarting和其他事件导航到另一个页面。在 W8.1 中,WebView 要好得多(例如,被视为常规控件而不是浮动在所有其他控件之上,...)

  • 解析您的 HTML 并生成原生元素。我开始了这样的实现并创建了一个 XAML 控件来显示带有本机控件的 HTML(请参阅https://mytoolkit.codeplex.com/wikipage?title=HtmlTextBlock)。但是,如果您有复杂的 HTML(例如 iframe 等),这可能不起作用,并且您别无选择,只能使用 WebView 控件。

于 2013-08-28T11:19:21.430 回答