在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中,我无法使用迭代性,因此我不知道如何使用触发器和EventToCommand。
感谢。
答案 0 :(得分:2)
这样的东西?
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>
希望这有帮助。