title: Binding to a command in a datagrid
body: <p>I am using the M-V-VM pattern in a WPF app.  I am binding a ViewModel to a ContentControl and using a data template defined in the window resources to render the view (a UserControl) for that ViewModel.</p>
  
  <p>In the ViewModel, I have a collection of items.  I'm binding that collection to the data grid provided in the WPF toolkit.  Also in the view model, I have a RemoveItem command defined which takes an argument for the item ID to remove.</p>
  
  <p>How would I bind to that command in the data grid?  The grid's data context is that collection, so something like:</p>
  
  <pre><code>&lt;Button Command="{Binding Path=RemoveCommand}" CommandParameter="{Binding Path=id}"&gt;X&lt;/Button&gt;
  </code></pre>
  
  <p>doesn't work - it can't find the command.  I think I need to do RelativeSource binding, but what would that look like?  Would the Ancestor type be UserControl, or the ContentControl?  Where is my ViewModel residing as the DataContext? </p>
  
  <p>Or am I way off here?</p>