c# - Multiple parameters with Command binding -
I have a text block using Command Binding and Prism Library.
This XAML part is:
and the model behind it is:
Public SearchView Model () {var eventAggregator = ServiceLocator.Current.GetInstance & lt; IEventAggregator & gt; (); FindCommand = New DelegateCommand (() => eventAggregator.GetEvent & lt; SSNChangedEvent & gt; Publish (SSN), () => String.IsNullOhWhiteSpace (Kennitala)); } Common Delayed Command Search Commands {Receive; Set; } Private string SSN; Public string SSN {return {ssn; } Set {if (SSN == value) returns; Ssn = value; RaisePropertyChanged ((= = SSN); FindCommand.RaiseCanExecuteChanged (); }} and this gridview model that listens to trigger this event and fire functions with SSN as a function
< Code> Public category GridViewModel: NotificationObject {public GridViewModel () {var eventAggregator = ServiceLocator.Current.GetInstance & lt; IEventAggregator & gt; (); EventAggregator.GetEvent & LT; SSNChangedEvent & gt; () GetData. } Public Supervision Collection & lt; Investment & gt; Investing {Get; Set; } Private Zero GetData (string SSN) {var list = GeniusConnection.GetDataFromWebService (ssn); Investment = New Observational Collection & lt; Investment & gt; (List); RaisePropertyChanged ((= = input);}} How can I add another parameter, for example, the datetime parameter, the part that confuses me: < Pre> FindCommand = new DelegateCommand (() = & Event; Event Agent.Gate Event (). Publish (SSN), () => String.IsNullOhWhiteSpace (Kennitala) ); This publication function takes only one parameter and for this I can not see how many parameters I can easily add.
You should create a class that contains all the required parameters that you want to publish.
public class SSNChangedEventParams {public string SSN {get ; Set;} Public Date Time DT {get} set;} ...} and then publish an example of this class:
EventAggregator.GetEvent & lt; SSNChangedEvent & gt; () Publish (New SSNChangedEventParams () {SSN = SSN, Dt = DateTime.Now})
Comments
Post a Comment