Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 8.1 如何将WP8.1中的事件触发器与MVVM Light一起使用?_Windows Phone 8.1_Mvvm Light - Fatal编程技术网

Windows phone 8.1 如何将WP8.1中的事件触发器与MVVM Light一起使用?

Windows phone 8.1 如何将WP8.1中的事件触发器与MVVM Light一起使用?,windows-phone-8.1,mvvm-light,Windows Phone 8.1,Mvvm Light,在WPF应用程序中,要将命令与MVVM Light一起使用,我使用以下命令: xmlns:j="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" <j:Interaction.Triggers> <j:EventTrigger EventName="PreviewKeyDown"> <cmd:EventToCo

在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>
xmlns:j=“clr命名空间:System.Windows.Interactivity;assembly=System.Windows.Interactivity”
但是在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>
xmlns:interactive=“使用:Microsoft.Xaml.interactive”xmlns:Core=“使用:Microsoft.Xaml.Interactions.Core”

希望这有帮助。

是的,但这种方式的问题是,在WPF MVVM中,Light允许传递原始事件参数,但我认为这种方式是不可能的。通过这种方式,我可以在我的viewModel中获得原始事件args?@lvaroGarcía我不确定您使用它的目的,因此很难回答。但是,如果绑定到任何属性并设置
Mode=TwoWay
,则视图模型应该相应地更新。如果视图中不支持绑定属性,则可以创建
转换器
,以在视图和视图模型之间转换数据。