如何访问的WebView的NavigateToString财产在ListView [英] How to access NavigateToString property of a WebView in a ListView

查看:151
本文介绍了如何访问的WebView的NavigateToString财产在ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的ListView 包含,除其他事项外,一个的WebView 。当 ListViewItem的上选择了这个名单,我想结合HTML到的WebView 通过 NavigateToString 方法。

I've got a ListView which contains, among other things, a WebView. When a ListViewItem on this list is selected, I'd like to bind HTML to the WebView via the NavigateToString method.

的WebView需要在绑定列表(因为它是依赖于项目的列表),而必须的使用NavigateToString(如HTML内容从代码来了,是不是在网络上)

The WebView needs be in the bound list (as it's tied to a list of items), and must use NavigateToString (as the HTML content is coming from code, and is not on the web)

反正有做到这一点?如果是这样,什么是最好的方法是什么?

Is there anyway to do this? If so, what's the best way?

推荐答案

当然,你可以添加使用任何附加依赖项属性或附加行为 的行为,你可以绑定一个字符串,将导航到该字符串时,例如,当第一次分配价值变动(它)。

Of course, you can add an attached behavior using either an attached dependency property or a Behavior that you could bind a string to that will navigate to that string when the value changes (e.g. when it is first assigned).

另一个问题可以用它如何执行是虽然。我会认为WebView控件作为一个浏览器窗口,所以如果你有一百个项目在你的ListView,你可能不想为所有这些打造百年IE窗口。即使假设你使用默认VirtualizingStackPanel作为你的ListView的ItemsPanel - 这听起来像是很多问题的根源。我还没有尝试过,所以我可能是错的,但我宁愿尝试解析HTML和格式化它经常使用的TextBlocks。对于非常基本的HTML,如果你已经是纯文本和链接,您可以使用的WinRT XAML Toolkit的LinkedHtmlFragment延长了RichTextBlock。对于一些更看中你可能需要做一些自己的编码,或使用类似 HTML敏捷性包(虽然我如果它支持的WinRT尚未确定)。

The other problem could be though with how it performs. I would think of the WebView control as a browser window, so if you have a hundred items in your ListView you might not want to create a hundred IE windows for all of them. Even assuming you use the default VirtualizingStackPanel as the ItemsPanel of your ListView - this sounds like a source of many issues. I haven't tried that, so I might be wrong, but I would rather try parsing the html and formatting it for use in regular TextBlocks. For very basic html you could use the LinkedHtmlFragment extension of the WinRT XAML Toolkit with a RichTextBlock if all you have is plain text and links. For something more fancy you might need to do some coding yourself or use something like the HTML Agility Pack (though I am not sure if it supports WinRT yet).

这篇关于如何访问的WebView的NavigateToString财产在ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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