title: Binding a WPF ShortCut Key to a Command in the ViewModel
body: <p>I have a WPF app that is using the MVVM pattern. Hooking up buttons to the VM is pretty straight forward since they implement the ICommand. I have a context menu that works similar. The next step is to create shortcut keys for the context menu. I can't figure out how to get the shortcut key invoke the Command. Here is an example:</p>
  
  <pre><code>&lt;MenuItem Header="Update" Command="{Binding btnUpdate}" &gt;
      &lt;MenuItem.Icon&gt;
          &lt;Image Source="/Images/Update.png"
                 Width="16"
                 Height="16" /&gt;
          &lt;/MenuItem.Icon&gt;
      &lt;/MenuItem&gt;
  </code></pre>
  
  <p>now I've added this:</p>
  
  <pre><code>&lt;Window.InputBindings&gt;
      &lt;KeyBinding Key="U"
                  Modifiers="Control" 
                  Command="{Binding btnUpdate}" /&gt;
  &lt;/Window.InputBindings&gt;
  </code></pre>
  
  <p>to try and connect the shortcut keys to the same binding, but this doesn't work. The error is:</p>
  
  <blockquote>
    <p>Error  169 A 'Binding' cannot be set on the 'Command' property of type 'KeyBinding'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.</p>
  </blockquote>
  
  <p>Isn't there a way to hook up this event to the Command? I can't figure this out.</p>
  
  <p>thanks in advance!</p>
  
  <p>Bill</p>