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.

Author: Li fengtong; Source: http://www.cnblogs.com/phoenixtrees. Http://www.cnblogs.com/phoenixtrees/archive/2011/05/05/2037676.html

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.