I had (note Extras.WP7):
<phone:PhoneApplicationPage
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7"
>
…and it was working fine for my EventToCommand stuff like this:
<phone:PhoneApplicationPage.Resources>
<i:EventTrigger x:Key="KeyPadButtonTrigger" EventName="Click">
<cmd:EventToCommand Command="{Binding Path=KeyPadButtonCommand}" CommandParameter="{Binding ElementName=Self, Path=Content }" />
</i:EventTrigger>
</phone:PhoneApplicationPage.Resources>
But then I wanted to use MmvmLight’s ButtonBaseExtensions like this:
<Button x:Name="button1"
cmd:ButtonBaseExtensions.Command="{Binding KeyPadButtonCommand}"
cmd:ButtonBaseExtensions.CommandParameter="{Binding ElementName=button1, Path=Content }"/>
…but when I did that I got "The attachable property 'Command' was not found in type 'ButtonBaseExtensions'" errors.
I found I had to add a namespace for assembly=GalaSoft.MvvmLight.WP7 as well, like this:
<phone:PhoneApplicationPage
xmlns:cmdxtras="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.WP7"
>
Note that I have BOTH xmlns:cmdxtras and xmlns:cmd. Things don’t work if I only have one or the other!
This seems really clumsy and doesn’t jive with what I think others are suggesting. Why do I need both?
The Extras assembly exists because EventToCommand requires a reference to System.Windows.Interactivity, while ButtonBaseExtensions, RelayCommand, Messenger etc do not need it. Some people are reluctant to add references to assemblies if they can avoid it. So for those people who don’t need EventtoCommand, they onlu use the base assembly, and the others who want the whole program can add Extras.
Cheers,
Laurent