wpf Mvvmlight 工具包 WPF4.5 中不存在 EventToCommand

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14301527/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 07:00:25  来源:igfitidea点击:

EventToCommand don't exist in Mvvmlight toolkit WPF4.5

wpfmvvm-light

提问by TinySnake

I'm using the latest MVVMLight Tookit at version 4.1.26.24928, and I'm writing a program using WPF 4.5.

我正在使用版本为 4.1.26.24928 的最新 MVVMLight 工具包,并且正在使用 WPF 4.5 编写程序。

Now I can't use the EventToCommand in VS2012 XAML file, it says "EventToCommand" does not exist in the namespace "clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.WPF45".

现在我无法在 VS2012 XAML 文件中使用 EventToCommand,它说命名空间 "clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.WPF45" 中不存在 "EventToCommand"

My dll references are:

我的 dll 引用是:

System.Windows.Interactivity (v4.5.0.0)

Galasoft.MvvmLight.WPF45 (v4.1.26.24928)

Galasoft.MvvmLight.Extras.WPF45 (v4.1.26.24928)

This is my code:

这是我的代码:

namespaces:

命名空间:

xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.WPF45"

the textblock:

文本块:

<TextBlock>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="MouseDown">
            <cmd:EventToCommand></cmd:EventToCommand>
        </i:EventTrigger>
    </i:Interaction.Triggers>
</TextBlock>

Am I did somthing wrong?Thank you!

我做错了什么吗?谢谢!

回答by wojjas

I had a similar problem, using VS2013. Mine said:

我有一个类似的问题,使用 VS2013。我的说:

EventToCommand does not exist in the namespace "http://www.galasoft.ch/mvvmlight"

EventToCommand 在命名空间“ http://www.galasoft.ch/mvvmlight”中不存在

Which sounded like nonsense since everything seemd to match... and the project was runing after rebuild/clean/whatever.

这听起来像是无稽之谈,因为一切似乎都匹配......并且该项目在重建/清理/任何之后运行。

Solution:

解决方案

1) Using NuGet (right-click on project in Solution Explorer) I uninstalled the "MVVM Light Libraries only" (it asked if I wanted to uninstalled the related CommonServiceLocator, I said: yes, whatever)

1)使用NuGet(在解决方案资源管理器中右键单击项目)我卸载了“MVVM Light Libraries only”(它问我是否要卸载相关的CommonServiceLocator,我说:是的,随便)

Rebuild, (just in case) It gave a lot of errors as expected, the ones about EventToCommand were still there.

重建,(以防万一)它按预期给出了很多错误,关于 EventToCommand 的错误仍然存​​在。

2) Using NuGet I now installed the "MVVM Light Libraries only". Rebuilt and now it works. No errors, no warnings, rock on ;-)

2) 使用 NuGet 我现在安装了“MVVM Light Libraries only”。重建,现在可以工作了。没有错误,没有警告,继续前进 ;-)