double click on row

Dec 1, 2008 at 2:51 PM
Hi group,
I'm starting with this wonderful new tool and I've a naive question: in a readonly datagrid, what is the suggested way of handling a mouse double click on a row (e.g. typically to edit the record into a separate window)? E.g. I could handle MouseDoubleClick bubbling from datagrid children, but this also includes the scrollbar buttons so that when the user rapidly clicks the scrollbar arrows a double click is detected but it's not wanted; in this case, I could examine the MouseDoubleClick event arguments for the original sender, so that I can exclude unwanted clicks, but I'm not sure about the source objects types to exclude or include (we might have complex templates in the row cells), so it does not seem an optimal solution. Or should I use some triggers in a row style? Or what else?

Thanks to all!
Dec 1, 2008 at 3:03 PM

I would handle the MouseDoubleClick event as you mentioned, then navigate the visual tree to determine whether the click occurred within a DataGridRow. See th following example for detecting whether a click occurred on a header or a cell:

Colin E.
-- - my WPF blog - WPF DataGrid Practical Examples

Dec 2, 2008 at 10:22 AM
Thank you very much Colin, this is what I needed!