DataGrid DoubleClickToCommand?

May 16, 2012 at 8:48 PM

I'm looking for an easy way to trigger a command when a row in a bound DataGrid is double-clicked i.e. bring up a details form.

I see that there is a DoubleClickToCommand trigger available in Catel but I'm not sure how to implement it for a DataGrid.  Are there any examples available?  I believe this should be a fairly common scenario.

May 16, 2012 at 9:12 PM

The datagrid has a MouseDoubleClick, so you can use the EventToCommand behavior.

May 17, 2012 at 2:51 PM

That will work in most cases but it breaks down if the user double-clicks a non-row item such as a column header.  In that case the command would still execute when I don't want it to.  I realize I may be out of luck because the WPF grid doesn't have a CellDoubleClick event like the Windows DataGridView does which allows you to know where the user clicked.

May 17, 2012 at 6:15 PM

In your canexecute, you cannot check whether SelectedRow != null? Adding a DoubleClickToCommand to every row is way too complex for performance.