title: Passing parameters to MVVM Command
body: <p>Does anyone knows how to pass parameters to <code>Command</code> using <code>CommandHandler</code>? Let's assume I would like to pass string hard coded value from XAML. I know how to pass from XAML, but not how to handle it in MVVM code behind. The code below works fine if there is no need to pass any parameters.</p>
  
  <pre class="lang-cs prettyprint-override"><code>public ICommand AttachmentChecked
  {
      get
      {
          return _attachmentChecked ?? (_attachmentChecked = new CommandHandler(() =&gt; ExecuteAttachmentChecked(), CanExecuteAttachmentChecked()));
      }
  }
  
  private void ExecuteAttachmentChecked()
  {        
  }
  
  private bool CanExecuteAttachmentChecked()
  {
      return true;
  }
  </code></pre>
  
  <p>CommandHandler:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class CommandHandler : ICommand
  {
      private Action _action;
      private bool _canExecute;
  
      public CommandHandler(Action action, bool canExecute)
      {
          _action = action;
          _canExecute = canExecute;
      }
  
      public bool CanExecute(object parameter)
      {
          return _canExecute;
      }
  
      public event EventHandler CanExecuteChanged;
  
      public void Execute(object parameter)
      {
          _action();
      }
  }
  </code></pre>