Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVVM Light and EventToCommand gives Invalid Markup in VS2015

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.

like image 360
Per Salmi Avatar asked Sep 09 '15 10:09

Per Salmi


2 Answers

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

like image 94
Raghuveer Avatar answered Nov 09 '22 01:11

Raghuveer


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

like image 40
Trev Avatar answered Nov 09 '22 01:11

Trev