title: ICommand with Parameter
body: <p>I found this: <a href="https://stackoverflow.com/questions/16172462/close-window-from-viewmodel">Close Window from ViewModel</a> which gets me started down the path of modifying my DelegateCommand class to handle parameters.  But I am not able to get the syntax worked out.</p>
  
  <p>Here is my DelegateCommand class, and the DelegateCommand class that I'm trying to create with little success:</p>
  
  <pre><code>    public class DelegateCommand : ICommand
      {
          private readonly Action _action;
  
          public DelegateCommand(Action action)
          {
              _action = action;
          }
  
          public void Execute(object parameter)
          {
              _action();
          }
  
          public bool CanExecute(object parameter)
          {
              return true;
          }
  
  #pragma warning disable 67
          public event EventHandler CanExecuteChanged { add { } remove { } }
  #pragma warning restore 67
      }
  
      public class DelegateCommand&lt;T&gt; : ICommand
      {
          private readonly Action _action;
  
          public DelegateCommand(Action action)
          {
              _action = action;
          }
  
          public void Execute(object parameter)
          {
              _action();
          }
  
          public bool CanExecute(object parameter)
          {
              return true;
          }
  
  #pragma warning disable 67
          public event EventHandler CanExecuteChanged { add { } remove { } }
  #pragma warning restore 67
      }
  </code></pre>
  
  <p>And here is what I do in the viewmodel:</p>
  
  <pre><code>public ICommand RowEditEndingAction
  {
      get { return new DelegateCommand(RowEditEnding); }
  }
  
  public ICommand UpdateDatabaseClick
  {
      get { return new DelegateCommand&lt;object&gt;(UpdateDatabase); } //THIS LINE HAS THE ERROR
  }
  </code></pre>
  
  <p>And the actual method that will get called:</p>
  
  <pre><code>public void UpdateDatabase(object parameter)
  {
      Window w = (Window)parameter;
      // A bunch of stuff that works is removed for brevity
      w.Close();
  }
  </code></pre>
  
  <p>The compiler does not like my UpdateDatabaseClick, specifically saying there is something wrong with the arguments to DelegateCommand, but I am at a loss as to what I am doing wrong (though I am thinking it is syntax . . . ).  What do I need to change?  This all worked before I added the parameter to UpdateDatabase, and just had the DelegateCommand (no template class).  But in that case I could not close the window.</p>