title: Pass CommandParameter to Command in Silverlight using MVVM
body: <p>I'm just learning Silverlight and looking at MVVM and Commanding.</p>
  
  <p>Ok, so I have seen the basic RelayCommand implementation:</p>
  
  <pre><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>
  
  <p>How can I pass a parameter down with a Command using this?</p>
  
  <p>I've seen that you can pass a <code>CommandParameter</code> like this:</p>
  
  <pre><code>&lt;Button Command="{Binding SomeCommand}" CommandParameter="{Binding SomeCommandParameter}" ... /&gt;
  </code></pre>
  
  <p>In my ViewModel, I need to create the Command, but <code>RelayCommand</code> is expecting an <code>Action</code> delegate. Can I implement <code>RelayCommand&lt;T&gt;</code> using <code>Action&lt;T&gt;</code> - if so, how do I do it and how to I use it?</p>
  
  <p>Can anyone give me any practical examples on CommandParameters with MVVM that don't involve using 3rd-party libraries (e.g. MVVM Light) as I want to understand it fully before using existing libraries.</p>
  
  <p>Thanks.</p>