WebWrowser Source属性的TwoWay绑定

时间:2012-06-18 13:08:25

标签: wpf xaml browser

我在WPF,MVVM应用程序中使用System.Windows.Controls.WebBrowser。

当加载的html文档发生变化时,我需要让WebBrowser的ViewModel知道WebBrowser的Source属性何时发生了变化。当然,最好的方法是将Source属性绑定到ViewModel,但我找到了这个绑定解决方案,它只提供从ViewModel到WebBrowser的单向绑定:databind the Source property of the WebBrowser in WPF

命名空间System.Windows.Forms中的旧WebBrowser有一些有用的方法,如“OnDocumentTitleChanged”,但我在System.Windows.Controls.WebBrowser中找不到类似的东西。

1 个答案:

答案 0 :(得分:0)

尝试收听WebBrowser.Navigated& WebBrowser.Navigating并使用WebBrowser.Source向您的VM发送代码消息,并在您的VM上侦听它并处理它,除非您想要去核心MVVM,可以在其中一个事件上发生EventToCommand。