Search This Blog

Monday, October 24, 2016

Get Current Row WPF DataGrid

WPF > Controls > ItemsControl > DataGrid > ItemContainerGenerator > ContainerFromIndex

Returns the element corresponding to the item at the given index.

Example

How to get current row if row is not selected.

var index = dataGrid.Items.IndexOf(dataGrid.CurrentItem);


var row = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromIndex(index);