Webview 在Windows 8中将事件绑定到mvvm模型

Webview 在Windows 8中将事件绑定到mvvm模型,webview,windows-8,mvvm-light,Webview,Windows 8,Mvvm Light,我想在WebView中绑定事件,但有一个例外: 类型为“Windows.UI.Xaml.Markup.XamlParseException”的异常 在VK.exe中发生,但未在用户代码中处理 WinRT信息:无法添加类型为的实例 “Win8nl.Behaviors.EventToCommandBehavior”到类型的集合 “System.Collections.ObjectModel.ObservableCollection” 您可能知道,使用Windows SDK时,没有System.Int

我想在WebView中绑定事件,但有一个例外:

类型为“
Windows.UI.Xaml.Markup.XamlParseException
”的异常 在VK.exe中发生,但未在用户代码中处理

WinRT信息:无法添加类型为的实例 “
Win8nl.Behaviors.EventToCommandBehavior
”到类型的集合 “
System.Collections.ObjectModel.ObservableCollection

您可能知道,使用Windows SDK时,没有System.Interaction.dll。我试图在web(为Windows RT编译)或Blend文件夹中找到它,但找不到

我发现使用行为来连接viewmodel中控件和RelayCommand的事件

它们帮助我绑定已加载的事件以供查看: 以下是代码:

...
xmlns:WinRtBehaviors="using:WinRtBehaviors"
xmlns:Win8nl_Behavior="using:Win8nl.Behaviors"
DataContext="{Binding Login, Source={StaticResource Locator}}">

<WebView x:Name="webView" 
    Grid.Row="1"                 
    Grid.Column="1"
    HorizontalAlignment="Left"
    VerticalAlignment="Top" 
    ScrollViewer.VerticalScrollBarVisibility="Hidden"
    ScrollViewer.HorizontalScrollBarVisibility="Hidden"
    Height="420" Width="530">
    <WinRtBehaviors:Interaction.Behaviors>
        <Win8nl_Behavior:EventToCommandBehavior Event="LoadCompleted"       
                                            Command="WebViewLoadedCommand" />
        </WinRtBehaviors:Interaction.Behaviors>
    </WebView>
我还想获取NavigateEventsArgs参数,就像我在WP7和System.Interaction中所做的那样:

 <i:Interaction.Triggers>
     <i:EventTrigger EventName="Navigated">
         <mvvm:EventToCommand Command="{Binding NavigatedCommand, Mode=OneWay}" PassEventArgsToCommand="True" />
      </i:EventTrigger>
 </i:Interaction.Triggers>

谢谢

你想要的

此开源项目为WinRT实现交互.Triggers

 <i:Interaction.Triggers>
     <i:EventTrigger EventName="Navigated">
         <mvvm:EventToCommand Command="{Binding NavigatedCommand, Mode=OneWay}" PassEventArgsToCommand="True" />
      </i:EventTrigger>
 </i:Interaction.Triggers>