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:
The tag 'EventToCommand' does not exist in XML namespace 'clr-namespace:GalaSoft.MvvmLight;assembly=GalaSoft.MvvmLight'.
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?
Edit:
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"
I can compile project now, but I still get errors in xaml (what is weird):
A value of type 'EventToCommand' cannot be added to a collection or dictionary of type 'TriggerActionCollection'
and
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.
and xaml editor can't display window properly (invalid markup).
Edit2:
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.
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"
I found this at the bottom the release notes here: http://www.mvvmlight.net/installing/changes/
Details XmlnsDefinitionAttribute for GalaSoft.MvvmLight.Command in Extras assembly
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:
Before:
<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">
After:
<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">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With