title: Having multiple Controls using the same CommandBinding in WPF?
body: <p>In my Window, there are several controls which perform the same action.</p>
  
  <p>For example I have a <code>MenuItem</code></p>
  
  <pre><code>&lt;MenuItem x:Name="_mnuNew" Command="New" Header="_New" InputGestureText="Ctrl+N"/&gt;
  </code></pre>
  
  <p>and a <code>Button</code></p>
  
  <pre><code>&lt;Button x:Name="_btnNew" Command="New"/&gt;
  </code></pre>
  
  <p>performing the "New" Command</p>
  
  <pre><code>&lt;Window.CommandBindings&gt;
      &lt;CommandBinding Command="New" CanExecute="IsNewExecuteable" Executed="NewExecute" /&gt;
  &lt;/Window.CommandBindings&gt;
  </code></pre>
  
  <p>The assignment works as desired for the <code>MenuItem</code>. Setting the Command for the <code>Button</code> results in a <strong>NullReferenceException</strong></p>
  
  <p>I've read <a href="http://www.wpf-tutorial.com/commands/using-commands/" rel="nofollow">here</a> that Command Bindings do also work on Buttons, so what am I doing wrong.</p>
  
  <p>EDIT:</p>
  
  <pre><code>    private void IsNewExecuteable(object sender, System.Windows.Input.CanExecuteRoutedEventArgs e)
      {
          e.CanExecute = IsRunning; //IsRunning is a siple property that is tested and works
      }
  </code></pre>