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)