title: WPF MVVM Commands: Multiple Command Parameters
body: <p>Perhaps my problem is more architectural than functional, but I am trying to bind a TextBox to a command, and in that command, i'd like to pass multiple parameters (i.e. a custom object). Not sure how to do this in declarative fashion (xaml).</p>
  
  <p><strong>ViewA (sits on top of ViewModelA)</strong>
  it has a TextBox, which is bound to <strong>CommandX</strong></p>
  
  <p><strong>ViewB (sits on top of ViewModelB)</strong> <em>(this is in fact another user control within the same Window as ViewA)</em>
  When commandX fires, ViewModelB needs to execute some method. ViewModelB needs to be updated with multiple properties before it can execute that method. </p>
  
  <p>My question is, how can i structure my command/architecture, so that ViewModelB has sufficient information to execute its method.</p>
  
  <p>side note: ViewModelA has all the necessary info for ViewModelB to execute its method. but, i don't want to get it from there, because later i'd want CommandX to be executed from different views</p>
  
  <p>update</p>
  
  <p>it appears that i could set CommandParameter property separately, which could likely be bound to a complex type in ViewModelA. That should be sufficient to suff all necessary properties into it.  </p>
  
  <p>awesome</p>
  
  <p>this worked! here is what my parmeter property looks like on ViewA</p>
  
  <pre><code>    public ExecuteQueryCommandParameters ExecuteQueryParameters {
          get {
              var p = new ExecuteQueryCommandParameters();
              p.AllColumns = ColumnsMaster;
              p.DatabaseName = SelectedDatabase;
              p.ServerName = SelectedServer;
              p.TopRows = 20;
              p.ViewModelName = "MainDataView";
  
              return p;
          }
      }
  </code></pre>
  
  <p>and the button implementation</p>
  
  <pre><code>&lt;Button Command="{Binding ExecuteQuery}" CommandParameter="{Binding ExecuteQueryParameters}"&gt;Top 20&lt;/Button&gt;
  </code></pre>
  
  <p>update</p>
  
  <p>there is a small road block with this solution. the commandparameter is bound to the property. but it retrieves it at load time, not at the time of command being executed. I need it to happen at command execution time, so that all the properties have latest values. any  ideas on how to achieve that ? </p>