我(注Extras.WP7
):为什么MvvmLight.Command _and_ MvvmLight.Extras.WP7都需要?
<phone:PhoneApplicationPage
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7"
>
...这是工作的罚款我EventToCommand这样的东西:
<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>
但后来我想用MmvmLight的ButtonBaseExtensions
这样的:
<Button x:Name="button1"
cmd:ButtonBaseExtensions.Command="{Binding KeyPadButtonCommand}"
cmd:ButtonBaseExtensions.CommandParameter="{Binding ElementName=button1, Path=Content }"/>
......但是当我这样做时,我得到"The attachable property 'Command' was not found in type 'ButtonBaseExtensions'"
错误。
,我发现我不得不添加一个命名空间assembly=GalaSoft.MvvmLight.WP7
为好,像这样:
<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"
>
注意,我都xmlns:cmdxtras
和xmlns:cmd
。如果我只有一个或另一个,事情就不会起作用!
这看起来非常笨拙,并没有与我认为别人所暗示的一致。为什么我需要两个?