WPF MVVM (STEP4)-Using prism (2)

Source: Internet
Author: User

The previous article briefly describes the use of Notificationobject in Prism, as well as Delegatecommand. This article is more simple, just describe how to use delegatecommand<t>.

The ICommand interface is the first to provide a method with parameters, and we often encounter the use of that parameter is useless, Prism also helped us. Of course, Prism does not forget that we sometimes have to drop the parameters.

In terms of definitions, we use ICommand definitions, like Delegatecommand and delegatecommand<t>. In the instantiation of the difference, of course, the interface binding timing also has a difference, detailed as follows:

Testparametercommand = new delegatecommand<string> (testparameter);
private void Testparameter (string para)        {            TESTSTR = para + "para";        }
<button grid.row= "2" content= "Testparameter" command= "{Binding Testparametercommand}" commandparameter= "{Binding Text, Elementname=textbox} "/>

The following is the command call with the code "with parameters", if the direct null without parameters is passed.

  private void Button_Click (object sender, RoutedEventArgs e)        {            (this. DataContext as Testviewmodel). Testparametercommand.execute ("Testpara");        }

This is how prism is introduced in MVVM, and the main prism is not limited to MVVM, but it is not a simple job to introduce the Prism bar later.

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

WPF MVVM (STEP4)-Using prism (2)

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.