I am trying to access each cell content when DataGridRow
is loaded, but the DataGridColumn.GetCellContent(DataGridRow)
is always null though there is data in the DataGridRow for that column.
For ex:
void DataGrid_LoadingRow(object sender,DataGridRowEventArgs e)
{
foreach(var colItem in dg.Columns)
{
var cell=item.GetCellContent(e.Row as DataGridRow);//Row is not null, cell is null after this execution.
}
}
what could be the reason?
PS: I have disabled Virtualisation of both rows and columns.
Thanks
When DataGrid
is about loading row data in a DataGridRow
and populating a row, it seems at first it raises the LoadingRow
event before appling Data Bindings, etc. Therefore content of its DataGridCell
s will be null at this point.
It is a thing similar PropertyChanging
event (that fires before appling of change). Whereas PropertyChanged
event fires after that change occured.
You can use another event for this purpose.