Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.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
是否有方法在Microsoft.Xaml.Behaviors.Wpf中使用MVVMLight的EventToCommand?_Wpf_Eventtocommand - Fatal编程技术网

是否有方法在Microsoft.Xaml.Behaviors.Wpf中使用MVVMLight的EventToCommand?

是否有方法在Microsoft.Xaml.Behaviors.Wpf中使用MVVMLight的EventToCommand?,wpf,eventtocommand,Wpf,Eventtocommand,我使用了System.Windows.Interactivity.WPF库和MVVM Light 我删除了System.Windows.Interactivity.WPF库,因为它的发布日期较旧。我安装了Microsoft.Xaml.Behaviors.Wpf库并更新了相关内容 工作进展顺利,只有一个例外。 问题是,如果我使用Microsoft.Xaml.Behaviors.Wpf与MVVMLight的EventToCommand的交互(如下所示),编译器将显示错误 xmlns:i="http

我使用了System.Windows.Interactivity.WPF库和MVVM Light

我删除了System.Windows.Interactivity.WPF库,因为它的发布日期较旧。我安装了Microsoft.Xaml.Behaviors.Wpf库并更新了相关内容

工作进展顺利,只有一个例外。 问题是,如果我使用Microsoft.Xaml.Behaviors.Wpf与MVVMLight的EventToCommand的交互(如下所示),编译器将显示错误

 xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 xmlns:mvvm="http://www.galasoft.ch/mvvmlight"

<i:Interaction.Triggers>
    <i:EventTrigger EventName="SelectedItemChanged">
        <mvvm:EventToCommand Command="{Binding CPUSelectedCommand}"
                         PassEventArgsToCommand="True"
                         EventArgsConverter="{localConverters:SelectedItemConverter}" />
    </i:EventTrigger>
</i:Interaction.Triggers>
xmlns:i=”http://schemas.microsoft.com/xaml/behaviors"
xmlns:mvvm=”http://www.galasoft.ch/mvvmlight"
错误消息为“错误MC3074:XML命名空间“”中没有EventToCommand标记。”

如果我使用CallMethodAction或InvokeCommand Microsoft.Xaml.Behaviors.Wpf,那么效果很好,但是我必须使用EventToCommand,因为要将参数传递给命令

我应该做什么来解决这个问题? 有人能告诉我解决办法吗

谢谢阅读。

简短回答:没有

MvvmLight中的
EventToCommand
类继承自
System.Windows.Interactivity.TriggerAction
,不能添加到
Microsoft.Xaml.Behaviors.EventTrigger
Actions
属性中

因此,您的选择是:

  • 恢复使用
    System.Windows.Interactivity.dll
  • 创建您自己的
    EventToCommand
    类型,该类型继承自
    Microsoft.Xaml.Behaviors.TriggerAction
    。您可以从上的现有实现开始

  • 谢谢你的回答