我使用 Entity Framework 7 和 gridview 在 gridview 中查看和编辑数据。编辑单元格后,我需要保存新值,但在更改源数据(ItemsSource 属性)和数据库之前调用的 CellEditEnding 事件不会更新。
事件监听代码:
private void DataGrid_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e)
{
if (e.EditAction == System.Windows.Controls.DataGridEditAction.Commit)
{
App.DBContext.SaveChanges();
}
}
提前谢谢!