WPF practice 5: MVVM Light Toolkit (V. Command)

Source: Internet
Author: User
Tags visual studio 2010

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.