title: Call Command from Code Behind
body: <p>So I've been searching around and cannot find out exactly how to do this.  I'm creating a user control using MVVM and would like to run a command on the 'Loaded' event.  I realize this requires a little bit of code behind, but I can't quite figure out what's needed.  The command is located in the ViewModel, which is set as the datacontext of the view, but I'm not sure exactly how to route this so I can call it from the code behind of the loaded event.  Basically what I want is something like this...</p>
  
  <pre><code>private void UserControl_Loaded(object sender, RoutedEventArgs e)
  {
      //Call command from viewmodel
  }
  </code></pre>
  
  <p>Looking around I can't seem to find the syntax for this anywhere.  Do I need to bind the command in the xaml first to be able to reference it?  I notice the command bindings option within a user control will not let you bind commands as you can within something like a button...</p>
  
  <pre><code>&lt;UserControl.CommandBindings&gt;
      &lt;CommandBinding Command="{Binding MyCommand}" /&gt; &lt;!-- Throws compile error --&gt;
  &lt;/UserControl.CommandBindings&gt;
  </code></pre>
  
  <p>I'm sure there's a simple way to do this, but I can't for the life of me figure it out.  </p>