MVVM Light和适当的名称空间 [英] MVVM Light and the proper namespace

查看:77
本文介绍了MVVM Light和适当的名称空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了MVVM Light软件包(工具>扩展和更新> MVVM Light for VS2015)

I just installed the MVVM Light package (Tools>Extensions and Updates > MVVM Light for VS2015)

当我开始我的项目时,我选择MVVM WPF项目选项(哦,男孩,它是否包含额外的.cs文件,真令人头疼),并且我想除其他外使用xaml中的EventTrigger,它说找不到cmd:EventToCommand.

When I start my project, I choose the MVVM WPF project option (oh boy, does it include extra .cs files, what a headache), and I'd like to amongst other things use the EventTrigger in xaml, it says that cmd:EventToCommand was not found.

我有以下名称空间:

xmlns:cmd =" clr-命名空间:GalaSoft.MvvmLight.Command; assembly = GalaSoft.MvvmLight.Extras.WPF45"

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

有人知道为什么找不到cmd:EventToCommand吗?

Does anyone know why it can't find cmd:EventToCommand ?

当我将命名空间更改为:

I should mention, when I change the namespace to:

xmlns:cmd =" clr-命名空间:GalaSoft.MvvmLight.Command; assembly = GalaSoft.MvvmLight.Platform"

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

它找到了cmd:EventToCommand,但是现在它说程序集'GalaSoft.MvvmLight.Platform中的'EventToCommand'是使用较早版本的Blend SDK生成的,Windows Presentation Framework 4项目中不支持它?

it finds cmd:EventToCommand, but now it says that 'EventToCommand' from assembly 'GalaSoft.MvvmLight.Platform is built with an older version of Blend SDK, and is not supported in Windows Presentation Framework 4 project??

发生了什么事?

MarcinMR

推荐答案

应为:

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

>>找到了cmd:EventToCommand,但是现在它说来自程序集"GalaSoft.MvvmLight.Platform"的"EventToCommand"是使用较早版本的Blend SDK构建的,Windows Presentation Framework不支持4个项目?

您需要在Project-> Properties-> Application-> Target Framework下将应用程序的目标框架更改为.NET Framework 4.5或更高版本.

You need to change the target framework of your application to .NET Framework 4.5 or later under Project->Properties->Application->Target Framework.

如果使用此版本,请确保还引用了正确版本的System.Window.Interactivity.dll: http://stackoverflow.com/questions/32477728/mvvm-light-and-eventtocommand-gives-invalid-markup-in-vs2015

Also make sure that the correct version of System.Window.Interactivity.dll is referenced if you use this one: http://stackoverflow.com/questions/32477728/mvvm-light-and-eventtocommand-gives-invalid-markup-in-vs2015

开始一个新项目,将目标框架设置为4.5或更高版本,然后使用Package Manager控制台(工具-> Nuget Package Manager)安装MvvmLight: https://www.nuget.org/packages/MvvmLight/

Start a new project, set the target framework to 4.5 or later and then install MvvmLight using the Package Manager Console (Tools->Nuget Package Manager): https://www.nuget.org/packages/MvvmLight/

这应该为您提供所有必需的组件.

This should get you the all required assemblies.

希望有帮助.

请记住,通过将有用的帖子标记为答案来关闭话题,然后在遇到新问题时开始新话题.请不要在同一线程中问几个问题.

Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.


这篇关于MVVM Light和适当的名称空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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