如何在 WP8.1 和 MVVM Light 中使用事件触发器?

How to use an event trigger in WP8.1 with MVVM Light?

在 WPF 应用程序中,要使用带有 MVVM Light 的命令,我使用这个:

xmlns:j="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"


<j:Interaction.Triggers>
        <j:EventTrigger EventName="PreviewKeyDown">
            <cmd:EventToCommand Command="{Binding SomeCommand}"> 
            </cmd:EventToCommand>
        </j:EventTrigger>
</j:Interaction.Triggers>

但是在WP8.1中我不能使用iteractivity,所以我不知道如何使用触发器和EventToCommand。

谢谢。

是这样的吗?

xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:Core="using:Microsoft.Xaml.Interactions.Core"

<Interactivity:Interaction.Behaviors>
    <Core:EventTriggerBehavior EventName="PreviewKeyDown">
        <Core:InvokeCommandAction Command="{Binding SomeCommand}"/>
    </Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>

希望对您有所帮助。