2
在celledit结束我想火法只有当值改变的Silverlight的DataGrid celleditended
我有一定的可编辑栏我想火只有当值已经改变
的DataGridCellEditEndedEventArgs财产e.EditAction
始终方法返回comitted
在celledit结束我想火法只有当值改变的Silverlight的DataGrid celleditended
我有一定的可编辑栏我想火只有当值已经改变
的DataGridCellEditEndedEventArgs财产e.EditAction
始终方法返回comitted
您可以收听DataGrid.PreparingCellForEdit事件(或可能DataGrid.BeginningEdit,但我不是100%正面),并存储该单元格的值。
然后,而不是听DataGrid.CellEditEnded
,而是倾听DataGrid.CellEditEnding。此事件专门为您提供取消编辑的选项,因此不会将其视为提交。 DataGridCellEditEndingEventArgs为它提供了一个Cancelbool
属性。检查新值是否与旧值相同,如果是,请将Cancel
属性设置为true
。那么当事件发生时,其EditAction
将为Cancel
。
void MyGrid_PreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs args)
{
//store current value
}
void MyGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs args)
{
//check if values are the same
if (valuesAreSame)
args.Cancel = true;
}