4.关于子视图, MVVMLight Using Two Views:http://www.codeproject.com/Articles/323187/MVVMLight-Using-Two-Views
3.这篇讲的不错:MVVM、MVVMLight、MVVMLight Toolkit之我见
2.using the code snippet:
a.in Visual Studio, in the code behind file, MainViewModel.cs, enter the letters mvvminpc and press tab. This will expand to a property, and by using tab you can set the property name to Customers and the backing variable to _customers.
1.使用教程:(WPFS) MVVM Light Toolkit: Soup To Nuts Part
<Button x:Name="Page2Button" Content="Page 2"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <Command:EventToCommand x:Name="Page2ButtonClicked" Command="{Binding Page2Command, Mode=OneWay}"/> </i:EventTrigger> </i:Interaction.Triggers> </Button>
但我发现,直接使用Command也有一样的效果:
<Button Command="{Binding Page2Command, Mode=OneWay}" Content="try easy"></Button>
对于这一点,文章下面也讨论了:
Dave T says:
Actually that does seem to me like a valid question. The Command property is supported on Button both in Silverlight 4 and Windows Phone 7.1.
-
But command cannot distinguish click and mouseover
Chris Andritzky says:
Now I got it: It’s because in Silverlight there is no Button.Command property. It’s only available in WPF.
-
Chris, if I’m understanding you correctly, you’re saying that if one were using WPF, all they’d have to do is something like this:
am I correct?
-
Chris, et. al, I’ve got another question concerning the Command property. I’ve checked and found that with the release of Silverlight 4, it supports the Command property on the ButtonBase class (from Tim Heuer’s blog). So then, I’m kind of confused as to what the need is to go through connecting a command using behaviors. Why not just use the Command property of the button class?
Chris Andritzky says:
I don’t see why we need the EventToCommand behavior here. Why not just simply bind the Button.Command property to Page2Command? This would also ensure that the button gets disabled when the command’s CanExecuteChanged method returns false.
I see that this is only an example, but it might be better to use an event for which there is no corresponding Command property (like ComboBox. SelectionChanged).