How to Select(highlight) the last row of the datagrid

Jan 22, 2009 at 4:06 AM

I am binding different DataTables dynamically for the DataGrid as the ItemSource. After assigning the ItemSource I want to select(highlight) the last row of the datagrid. Is there any easy way to select the last row of the DataGrid?

Jan 22, 2009 at 8:01 AM

If you are binding a DataTable you can find its row count from DataTable.Rows.Count, you can then use this to select the last row by setting the DataGrid.SelectedIndex property.

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