DataGrid Row Selection

Dec 4, 2008 at 10:21 PM
What event do I want to fire when selecting a row in a WPF DataGrid to get at the SelectedItem for the row?

Tried PreviewMouseLeftButtonDown and MouseLeftButtonDown to do this, but each requires a double click to get the desired result. How do I get it working for a single click?

I have SelectionUnit="CellOrRowHeader" and SelectionMode="Single" set for the grid.



Dec 5, 2008 at 12:35 PM
What about listening to DataGrid.SelectionChanged?
Dec 5, 2008 at 12:45 PM
I'm not sure if this is the best method, but you can listen for the DataGrid's SelectionChanged event and then access the DataGrid's CurrentItem property.

Dec 5, 2008 at 1:35 PM
Thanks, I will give it a try.