title: Command Binding in XAML vs ICommand Properties in ViewModel
body: <p>I am just starting to use commanding with MVVM in an application. I've found a number of examples and have tried it both ways in my code. Some examples have the command binding in the xaml like so:</p>
  
  <pre><code>&lt;CommandBinding Command="local:MainWindow.OpenRecentFile" 
                  Executed="{Binding OpenRecentFile_Executed}" /&gt;
  ...
  &lt;MenuItem Header="{x:Static culture:TextResource.RecentFilesMenuItem}" 
            Command="local:MainWindow.RecentFilesCommand" &gt;
  </code></pre>
  
  <p>With OpenRecentFile_Executed being a method in the ViewModel and a static ICommand like so:</p>
  
  <pre><code> public static readonly ICommand OpenRecentFile = 
       new RoutedCommand("Open Recent", typeof(MainWindow));
  </code></pre>
  
  <p>I have also seen where there is a property on the ViewModel that is of type ICommand that is bound to in the View like so:</p>
  
  <pre><code>&lt;MenuItem Header="Close Current File" 
            Command="{Binding CloseCurrentFileCommand}" 
            CommandParameter="{TemplateBinding DataContext}"/&gt;
  </code></pre>
  
  <p>and in the ViewModel:</p>
  
  <pre><code>private ICommand closeCurrentFileCommand;
  public ICommand CloseCurrentFileCommand
  {
      get
      {
          if (closeCurrentFileCommand == null)
          {
              closeCurrentFileCommand = 
                  new RelayCommand(param =&gt; this.CloseCurrentCedarFile(param));
          }
          return closeCurrentFileCommand;
      }
  }
  </code></pre>
  
  <p>What are the benefits/drawbacks to each method?</p>