Thats correct - you're actually trying to access your WPF DataGrid as if it were a WinForms DataGridView (this is what I'm used to)
So, in your case, its
foreach (System.Data.DataRowView dr in yourDataGrid.ItemsSource)
{
}
I found another way in SO
var itemsSource = youDataGrid.ItemsSource as IEnumerable;
if (itemsSource != null)
{
foreach (var item in itemsSource)
{
var row = youDataGrid.ItemContainerGenerator.ContainerFromItem(item) as DataGridRow;
if (row != null)
{
.....
}
}
}
this may help further
Techie things: Get WPF DataGrid row and cell[
^]