MVVM Light和EventToCommand在VS2015中给出了无效的标记 [英] MVVM Light and EventToCommand gives Invalid Markup in VS2015

查看:472
本文介绍了MVVM Light和EventToCommand在VS2015中给出了无效的标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始将VS2015与包括MVVM Light工具包在内的现有WPF项目一起使用,但是发现WPF/Xaml设计器存在问题.

I was just about to start using VS2015 with an existing WPF project including MVVM Light toolkit but found that there is a problem with this regarding the WPF/Xaml designer.

该项目在标记中包含一些EventToCommand标记,如下所示:

The project includes a few EventToCommand tags in markup like this:

<i:Interaction.Triggers>
    <i:EventTrigger EventName="Loaded">
        <command:EventToCommand Command="{Binding LoadedCommand}"></command:EventToCommand>
    </i:EventTrigger>
</i:Interaction.Triggers>

使用EventToCommand构造加载xaml文件时,设计器无法加载文件并报告无效标记".错误列表将显示:

When loading xaml files using the EventToCommand construct the designer fails to load the file and reports "Invalid markup". The error list then shows:

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

该项目设置为以.NET 4.5为目标,并且在VS2013中完全可以正常运行,而无需进行任何更改.所有这些看起来都非常类似于问题在哪里可以找到Galasoft.MvvmLight.是WPF45汇编程序?,但是在那里提出的解决方案在VS2015中完全没有帮助.

The project is set to target .NET 4.5 and it works perfectly well i VS2013 without any changes at all. All this looks very similar to the question Where do I find Galasoft.MvvmLight.WPF45 assembly? but the suggested solution there does not help at all in VS2015.

我已经在由MVVM Light模板创建的新项目中对此进行了测试,但是该新项目也遇到了相同的错误. MVVM Light版本是NuGet的MvvmLightLibs 5.2.0,我还用较旧的MvvmLightLibs v4.x版本进行了测试.

I have tested this in a new project created from MVVM Light template but I get the same error with that new project too. The MVVM Light version is MvvmLightLibs 5.2.0 from NuGet, I have also tested with older v4.x version of MvvmLightLibs.

推荐答案

问题可能是由于缺少GAC中的System.Windows.Interactivity.dll注册所致.以下步骤将有助于避免无效的标记错误.

The problem might be due to missing registration of System.Windows.Interactivity.dll in GAC. The below steps would help avoiding the invalid markup error.

  1. 以管理员身份启动VS2015的开发人员命令提示符

  1. Start Developer Command Prompt for VS2015 as Admin

将目录更改为Blend SDK:
cd C:\ Program Files(x86)\ Microsoft SDKs \ Expression \ Blend \ .NETFramework \ v4.5 \ Libraries \

Change Directory to Blend SDK:
cd C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.5\Libraries\

注册DLL:
gacutil -i System.Windows.Interactivity.dll

Register DLL:
gacutil -i System.Windows.Interactivity.dll

参考: https://connect.microsoft.com/VisualStudio/feedback/details/755407/xaml-designer-will-not-display-when-using-blend-sdk-behaviors

这篇关于MVVM Light和EventToCommand在VS2015中给出了无效的标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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