WPF MVVM (STEP3)-Using prism (1)

Source: Internet
Author: User

When using WPF-MVVM development, the implementation of their own notification interface, Delegatecommand relatively less use, we are more use of the third-party MVVM framework, which Microsoft's own team provided by the PRISM framework, this framework is more functional, I now learn a limited, For the time being, let's introduce simple use.

Note: Prism version 4.1 is used here

Prism first convenient for us is to help us implement the INotifyPropertyChanged interface, where raisepropertychanged not only realizes the use of string notifications, but also realizes the lambda expression, which provides some convenience in code refactoring ...

Second, Prism helps us implement the ICommand interface, which can be implemented using its delegatecommand.

The following is a summary code:

 Class Testviewmodel:notificationobject {private string teststr; <summary>///For notification string///</summary> public string Teststr {get {R} Eturn Teststr;                } set {teststr = value;            raisePropertyChanged (() =>teststr); }}///<summary>///TEST command///</summary> public ICommand Testcommand {get ; Set        } public Testviewmodel () {Testcommand = new Delegatecommand (test,cantest);        } int i = 0;            <summary>///Testcommand Execution method///</summary> private void Test () {            i++;        Teststr = i.ToString (); }///<summary>//Testcommand available///</summary>//<returns></returns        > private bool Cantest () {return true; }    }

The Delegatecommand in Prism is used here, which is used to not pass parameters, and the following describes the use of delegatecommand<t> to create a command that can pass parameters.

Project code managed Address: https://wpfmvvm.codeplex.com/

WPF MVVM (STEP3)-Using prism (1)

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.