title: Passing a parameter to ICommand
body: <p>I have a simple button that uses a command when executed, this is all working fine but I would like to pass a text parameter when the button is clicked. </p>
  
  <p>I think my XAML is ok, but I'm unsure how to edit my <code>RelayCommand</code> class to receive a parameter:</p>
  
  <pre><code>&lt;Button x:Name="AddCommand" Content="Add" 
      Command="{Binding AddPhoneCommand}"
      CommandParameter="{Binding Text, ElementName=txtAddPhone}" /&gt;
  </code></pre>
  
  <pre class="lang-c# prettyprint-override"><code>public class RelayCommand : ICommand
  {
      private readonly Action _handler;
      private bool _isEnabled;
  
      public RelayCommand(Action handler)
      {
          _handler = handler;
      }
  
      public bool IsEnabled
      {
          get { return _isEnabled; }
          set
          {
              if (value != _isEnabled)
              {
                  _isEnabled = value;
                  if (CanExecuteChanged != null)
                  {
                      CanExecuteChanged(this, EventArgs.Empty);
                  }
              }
          }
      }
  
      public bool CanExecute(object parameter)
      {
          return IsEnabled;
      }
  
      public event EventHandler CanExecuteChanged;
  
      public void Execute(object parameter)
      {
          _handler();
      }
  }
  </code></pre>