Keywords: WPF. Net C # MVVM Light Toolkit framework Visual Studio 2010 VS2010 Expression Blend 4 getting started tutorial New Practice
V. Command
1. In LoginViewModel. cs, add the RelayCommand attribute LoginCommand as the Command object in response to the View-layer logon operation.
2. initialize the LoginCommand object in the LoginViewModel constructor.
When creating a LoginCommand object, two parameters are specified: Login () and CanLogin (), these two methods are used to perform the login operation and determine whether the login operation can be performed (actually corresponding to the Execute and CanExecute of ICommand ). The following describes the specific implementation of Login () and CanLogin.
3. In Blend 4, select "behavior" from the list on the "assets" tab, drag "EventToCommand" to the logon button, and change the default name to LoginButtonClick.
4. Bind the Command attribute of LoginButtonClick to LoginCommand, as shown in the following two figures.
Compiled.