Detecting Double Click Events on the WPF DataGrid

Either I missed the obvious solution, or there is indeed no simple way to catch double click events on a given row of Microsoft’s WPF DataGrid.

This snippet here fires the event whenever the grid is clicked – it doesn’t matter whether the user double-clicks into an empty area (no rows) or a row:

<!-- fires even if the user does not click a given row --><dg:DataGriddg:DataGridRow.MouseDoubleClick="OnDoubleClick"/>

As a result, I reverted to a workaround by searching the Visual Tree of the event source for an instance of type DataGridRow. In order to find the ancestor item, I used a snippet I posted here a while ago. Here’s the full code:

XAML:

<!-- just register a listener on the grid --><dg:DataGridMouseDoubleClick="OnDoubleClick"/>

Hi Folks, try this out:
Note: This works out for datagrids with whose binding source is a binding
list of objects ex: a binding list of employees with public properties

//create an event handler and hook up a delegate to it
private System.Windows.Input.MouseButtonEventHandler populateTextBox;
populateTextBox += doSOmething;
dataGrid1.MouseDoubleClick+= new System.Windows.Input.MouseButtonEventHandler( populateTextBox);

Hi,
I have come across this situation and need help, so in my wpf window there are two grids and a user control that we can drag. So i want that when its on grid1 it does thing1 and when its on grid2 it does thing2. How to implement this?