I'm trying to get a hold of all DataGridRows for a DataGrid, don't ask me why :) The DataGrid is bound to a DataView and I'm using this code but it failes after some rows.. I guess that they haven't been created yet.
foreach (DataRowView item in datagrid.Items)
{
// Sometimes row == null...
DataGridRow row = dataGrid.ItemContainerGenerator.ContainerFromItem(item) as DataGridRow;
// Use row...
}
Any way around this?