MVVM Light and EventToCommand gives Invalid Markup in VS2015
Asked Answered
S

2

8

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.

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>

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

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.

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.

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.

Sears answered 9/9, 2015 at 10:59 Comment(0)
V
4

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. Start Developer Command Prompt for VS2015 as Admin

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

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

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

Voyage answered 19/7, 2016 at 10:4 Comment(2)
This fixed the issue.Maltase
This connect link doesn't work. Google Cache version : webcache.googleusercontent.com/…Bolanos
S
1

Use this version of System.Windows.Interactivity: http://www.microsoft.com/en-us/download/details.aspx?id=10801

You can also install through NuGet Package Manager. Search for System.Windows.Interactivity.WPF

Speed answered 18/9, 2015 at 15:25 Comment(2)
Tried that but it immediately results in a XamlParseException when starting the application. Error message says: Could not load file or assembly 'System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.Sears
I also had to drop MVVM Light down to version 5.1.1.0Speed

© 2022 - 2024 — McMap. All rights reserved.