title: How to Bind Button to DataGrid Delete Command in WPF
body: <p>I'd like to delete rows from a WPF DataGrid by clicking a button above (not inside) the DataGrid, following the MVVM pattern. Although delete buttons within a row itself work, they are kind of ugly (one has to select the row first) and as there are also add and edit buttons next to the delete button, a delete button would better fit there, I think.
  The corresponding part in my ViewModel looks like this:</p>
  
  <pre><code>&lt;Button Grid.Row="0" Grid.Column="0" Content="add"/&gt;
  &lt;Button Grid.Row="0" Grid.Column="1" Content="edit"/&gt;
  &lt;Button Grid.Row="0" Grid.Column="2" Content="delete"/&gt;
  &lt;DataGrid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" 
      ItemsSource="{Binding dataTableListItems}"&gt;
      &lt;DataGrid.Columns&gt;
          &lt;DataGridTextColumn Header="Name"/&gt;
          &lt;!--I don't wan't to use these "in-Row" delete buttons--&gt;
          &lt;DataGridTemplateColumn Header="delete"&gt;
              &lt;DataGridTemplateColumn.CellTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;Button Command="Delete" Content="X"/&gt;
                  &lt;/DataTemplate&gt;
              &lt;/DataGridTemplateColumn.CellTemplate&gt;
          &lt;/DataGridTemplateColumn&gt;
      &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>Any ideas on how Command Binding for the buttons could look like? Or alternatively, I could also be satisfied if the <em>in-row</em> delete buttons would always be enabled and a click on one would delete the corresponding row <strong>without</strong> needing to select the row first.</p>