在加载DataGridRow时,我试图访问每个单元格内容,但是尽管该列的DataGridRow中有数据,但DataGridColumn.GetCellContent(DataGridRow)始终为null。前任:
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.
}
}可能是什么原因?
PS:我已经禁用了行和列的虚拟化。
谢谢
发布于 2016-04-12 11:33:10
当DataGrid是关于在DataGridRow中加载行数据并填充一行时,它似乎在应用数据绑定之前首先引发LoadingRow事件,因此它的DataGridCell的内容此时为null。
这是一个类似的PropertyChanging事件(在应用更改之前触发)。而PropertyChanged事件在该更改发生后触发。
为此,您可以使用另一个事件。
发布于 2016-07-30 22:53:19
这是一个软件错误,所以:
DataGridTemplateColumn而且效果会很好。
https://stackoverflow.com/questions/30394207
复制相似问题