title: Delete DataGrid row (WPF) by clicking Delete key button
body: <p>I have WPF 4 desktop-based application. In one of the windows of this application, I have <code>DataGrid</code> with data, bonded with SQL Server database (via ADO.NET Entity Framework). In order to manipulate data, I have a delete button, that deletes selected row from <code>DataGrid</code> and call <code>SaveChanges()</code> method.</p>
  
  <p>Now I want to add support for keyboard manipulations, e.g. I want to let the user remove the row by selecting and clicking on Delete keyboard button.</p>
  
  <p>If I set <code>CanUserDeleteRows="True"</code> in window XAML, it removes selected row but doesn't make commit to database, in other words, it doesn't call <code>SaveChanges()</code> method.</p>
  
  <p>I tried to add <code>keyDown</code> event handler to <code>DataGrid</code> a check <code>if (e.Key == Key.Delete)</code>, so run remove method that removes selected row and call <code>SaveChanges()</code> method, but it doesn't work.</p>
  
  <p>My question is how can I add keyboard event handler to <code>DataGrid</code> that will let remove selected row and call <code>SaveChanges()</code> method or just run my own method, that deals with row removing from <code>DataGrid</code> and make commit to DB.</p>
  
  <p>Of course, if you have any other idea, related to my question, feel free to suggest.</p>