问题是,当我以编程方式编辑datagrid中的列值并向下滚动时,这些值会在列的下一个单元格中重复显示。这似乎是虚拟化错误或“效果”,因为当我关闭它时,问题就消失了。我认为问题出在这个地方:
public void EditedCell(object oItem, string oColumnName, ref List<string> lErrors, object newValue = null)
{
DataGridRow dgRow = dgDati.ItemContainerGenerator.ContainerFromItem(oItem) as DataGridRow;
/* In other places, when I call EditedCell(DataGridRow, ...) it works fine.
The problem shows up only when I call EditedCell(object oItem, ...) */
EditedCell(dgRow, oColumnName, ref lErrors, newValue);
}
这是问题的屏幕。由于此问题,黄色单元格以编程方式更改,并显示其他包含0000的单元格。当我从DataSource读取数据时,它在DataRows中没有那些0000值:
另外,要设置单元格的值,我在单元格和DataRow值中设置单元格控件以更改值并正确显示:
if (oElement.GetType() == typeof(TextBox))
{
(oElement as TextBox).Text = newValue.ToString();
}
if (oElement.GetType() == typeof(TextBlock))
{
(oElement as TextBlock).Text = newValue.ToString();
}
有没有人见过类似的东西,知道怎么处理?