wpf 我在哪里可以找到 Galasoft.MvvmLight.WPF45 程序集?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26343678/
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 12:36:24  来源:igfitidea点击:

Where do I find Galasoft.MvvmLight.WPF45 assembly?

wpfmvvmmvvm-light

提问by Bartosz Rosa

I'm using VS2013 Express. I'm quite new in WPF and MVVM. I've downloaded mvvmlight using NuGet to my project. I'm tryinng to use GalaSoft_MvvmLight_Command:EventToCommand. As far as I know, I have to add reference in xaml by adding namespace:

我正在使用 VS2013 Express。我对 WPF 和 MVVM 还很陌生。我已经使用 NuGet 将 mvvmlight 下载到我的项目中。我正在尝试使用GalaSoft_MvvmLight_Command:EventToCommand. 据我所知,我必须通过添加命名空间在 xaml 中添加引用:

xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight"

But, unfortunatelly I get error, that says:

但是,不幸的是我得到错误,说:

The tag 'EventToCommand' does not exist in XML namespace 'clr-namespace:GalaSoft.MvvmLight;assembly=GalaSoft.MvvmLight'.

XML 命名空间“clr-namespace:GalaSoft.MvvmLight;assembly=GalaSoft.MvvmLight”中不存在标记“EventToCommand”。

I've found some information, that I have to include GalaSoft.MvvmLight.WPF45assembly, but I don't see this dll in packages\MvvmLightLibs.5.0.0.1\lib\ folder. There are many folders, for each .NET version etc, but each of these assemblies names are the same, without WPF45 sufix.What is going on? Where do I find this GalaSoft.MvvmLight.WPF45.dll assembly? Or maybe in version 5 was some changes made in names?

我找到了一些信息,我必须包含GalaSoft.MvvmLight.WPF45程序集,但我在包\MvvmLightLibs.5.0.0.1\lib\ 文件夹中没有看到这个 dll。对于每个 .NET 版本等,有很多文件夹,但是这些程序集名称中的每一个都相同,没有 WPF45 后缀。这是怎么回事?我在哪里可以找到这个 GalaSoft.MvvmLight.WPF45.dll 程序集?或者也许在第 5 版中对名称进行了一些更改?

Edit: Using object browser I found that EventToCommandis in GalaSoft.MvvmLight.Platform assembly in GalaSoft.MvvmLight.Command namespace. So I did

编辑:使用对象浏览器,我发现它EventToCommand位于 GalaSoft.MvvmLight.Command 命名空间中的 GalaSoft.MvvmLight.Platform 程序集中。所以我做了

xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Platform"

I can compile project now, but I still get errors in xaml (what is weird):

我现在可以编译项目,但我仍然在 xaml 中遇到错误(奇怪的是):

A value of type 'EventToCommand' cannot be added to a collection or dictionary of type 'TriggerActionCollection'

无法将“EventToCommand”类型的值添加到“TriggerActionCollection”类型的集合或字典中

and

The type 'EventToCommand' from assembly 'GalaSoft.MvvmLight.Platform' is built with an older version of the Blend SDK, and is not supported in a Windows Presentation Framework 4 project.

程序集“GalaSoft.MvvmLight.Platform”中的类型“EventToCommand”是使用旧版本的 Blend SDK 构建的,在 Windows Presentation Framework 4 项目中不受支持。

and xaml editor can't display window properly (invalid markup).

并且 xaml 编辑器无法正确显示窗口(无效标记)。

Edit2:

编辑2:

Solution for invalid markup.

无效标记的解决方案。

After I've changed the namespace to xmlns:cmd="http://www.galasoft.ch/mvvmlight"I also change project's target framework from 4.5 to 3.5. IDE shows an error about there are few NuGet packages that target other framework, so I returned to 4.5 - and it magically works now ;). Thanks all for help.

在我将命名空间更改为之后,xmlns:cmd="http://www.galasoft.ch/mvvmlight"我还将项目的目标框架从 4.5 更改为 3.5。IDE 显示一个错误,关于很少有针对其他框架的 NuGet 包,所以我返回到 4.5 - 现在它神奇地工作了;)。感谢大家的帮助。

采纳答案by Theodosius Von Richthofen

Here's how its done now in your XAML assuming you've got Version 4.0.0. Beat 1 or higher:

假设您拥有 4.0.0 版,以下是它现在在您的 XAML 中的完成方式。击败 1 或更高:

xmlns:cmd="http://www.galasoft.ch/mvvmlight"

xmlns:cmd="http://www.galasoft.ch/mvvmlight"

I found this at the bottom the release notes here: http://www.mvvmlight.net/installing/changes/

我在底部的发行说明中找到了这个:http: //www.mvvmlight.net/installing/changes/

Details XmlnsDefinitionAttribute for GalaSoft.MvvmLight.Command in Extras assembly

详细信息 XmlnsDefinitionAttribute for GalaSoft.MvvmLight.Command 在 Extras 程序集中

Thanks to the addition of XmlnsDefinitionAttribute, you can simplify the inclusion of the MVVM Light EventToCommand action in XAML. See the before and after below:

由于添加了 XmlnsDefinitionAttribute,您可以简化在 XAML 中包含 MVVM Light EventToCommand 操作的过程。请参阅下面的之前和之后:

Before:

前:

<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"

xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"

xmlns:cmd="http://www.galasoft.ch/mvvmlight"
x:Class="MvvmLight4.MainPage">

After:

后:

<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:cmd="http://www.galasoft.ch/mvvmlight"
x:Class="MvvmLight4.MainPage">

回答by Khan

EventToCommandexists in the Extrasassembly.

EventToCommand存在于Extras程序集中。

Try:

尝试:

xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras"


More Information:

更多信息:

To determine the assembly a class falls in, I usually Go To Definitionand the assembly is referenced in the region at the top of the [from metadata]code file.

为了确定一个类所属的程序集,我通常会转到定义,并在[from metadata]代码文件顶部的区域中引用该程序集。