double click on row

Dec 1, 2008 at 1: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 2:03 PM
Hi,

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:

http://www.codeplex.com/wpf/Thread/View.aspx?ThreadId=40845

Regards,
Colin E.
--
http://wpfadventures.wordpress.com/ - my WPF blog
http://www.codeproject.com/KB/WPF/WPFDataGridExamples.aspx - WPF DataGrid Practical Examples




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