在哪里可以找到Galasoft.MvvmLight.WPF45程序集? [英] Where do I find Galasoft.MvvmLight.WPF45 assembly?

查看:352
本文介绍了在哪里可以找到Galasoft.MvvmLight.WPF45程序集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS2013 Express.我在WPF和MVVM中是一个新手.我已经使用NuGet将mvvmlight下载到我的项目中.我正在尝试使用GalaSoft_MvvmLight_Command:EventToCommand.据我所知,我必须在xaml中通过添加名称空间来添加引用:

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:

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

但是,不幸的是,我得到了错误提示:

But, unfortunatelly I get error, that says:

标记"EventToCommand"在XML名称空间中不存在 'clr-namespace:GalaSoft.MvvmLight; assembly = GalaSoft.MvvmLight'.

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

我找到了一些必须包含GalaSoft.MvvmLight.WPF45程序集的信息,但是在packages \ MvvmLightLibs.5.0.0.1 \ lib \文件夹中看不到该dll.每个.NET版本都有很多文件夹,但是每个程序集名称都是相同的,没有WPF45 sufix.这是怎么回事?在哪里可以找到此GalaSoft.MvvmLight.WPF45.dll程序集?也许在版本5中,名称上做了一些更改?

I've found some information, that I have to include GalaSoft.MvvmLight.WPF45 assembly, 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?

使用对象浏览器,我发现EventToCommand在GalaSoft.MvvmLight.Command命名空间的GalaSoft.MvvmLight.Platform程序集中.所以我做了

Using object browser I found that EventToCommand is in GalaSoft.MvvmLight.Platform assembly in GalaSoft.MvvmLight.Command namespace. So I did

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

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

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

不能将类型'EventToCommand'的值添加到类型'TriggerActionCollection'的集合或词典中

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

程序集"GalaSoft.MvvmLight.Platform"中的"EventToCommand"类型是使用较早版本的Blend SDK构建的,Windows Presentation Framework 4项目中不支持该类型.

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.

和xaml编辑器无法正确显示窗口(标记无效).

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

Edit2:

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

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.

推荐答案

在XAML中,假设您已经安装了4.0.0版,现在该如何进行操作.击败1或更高:

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

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

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

我在此处的发行说明的底部找到了它: http://www.mvvmlight.net/安装/更改/

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

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

Details XmlnsDefinitionAttribute for GalaSoft.MvvmLight.Command in Extras assembly

由于添加了XmlnsDefinitionAttribute,因此可以简化XAML中对MVVM Light EventToCommand操作的包含.请参见下面的之前和之后:

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:

之前:

<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">

之后:

<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">

这篇关于在哪里可以找到Galasoft.MvvmLight.WPF45程序集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆