Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple parameters with Command binding
    text
    copied!<p>I have a textblock with command binding and using Prism library.</p> <p>this is the XAML parth:</p> <pre><code>&lt;TextBlock Margin="0,10,0,0"&gt;SocialSecurityNumer:&lt;/TextBlock&gt; &lt;TextBox Name="SSNText" GotFocus="TextBox_GotFocus" Text="{Binding SSN, UpdateSourceTrigger=PropertyChanged}" Margin="0,3,0,0"/&gt; </code></pre> <p>And this is the ViewModel behind:</p> <pre><code>public FindViewModel() { var eventAggregator = ServiceLocator.Current.GetInstance&lt;IEventAggregator&gt;(); FindCommand = new DelegateCommand( () =&gt; eventAggregator.GetEvent&lt;SSNChangedEvent&gt;().Publish(SSN), () =&gt; !string.IsNullOrWhiteSpace(Kennitala) ); } public DelegateCommand FindCommand { get; set; } private string ssn; public string SSN { get { return ssn; } set { if (ssn== value) return; ssn = value; RaisePropertyChanged(() =&gt; SSN); FindCommand.RaiseCanExecuteChanged(); } } </code></pre> <p>And this is the GridViewModel that listen for this event trigger and fire up a function with SSN as a parameter</p> <pre><code>public class GridViewModel : NotificationObject { public GridViewModel() { var eventAggregator = ServiceLocator.Current.GetInstance&lt;IEventAggregator&gt;(); eventAggregator.GetEvent&lt;SSNChangedEvent&gt;().Subscribe(GetData); } public ObservableCollection&lt;Investment&gt; Investments { get; set; } private void GetData(string ssn) { var list = GeniusConnection.GetDataFromWebService(ssn); Investments = new ObservableCollection&lt;Investment&gt;(list); RaisePropertyChanged(() =&gt; Investment); } } </code></pre> <p>How can i add another parameter, for example datetime parameter, the part that confuses me is:</p> <pre><code>FindCommand = new DelegateCommand( () =&gt; eventAggregator.GetEvent&lt;SSNChangedEvent&gt;().Publish(SSN), () =&gt; !string.IsNullOrWhiteSpace(Kennitala) ); </code></pre> <p>This Publish function takes just one parameter and therefor i don´t see how i can easily add multiple paramters.??</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload