Checking the datagrid example here
http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html
see the datagrid section
It says that if escape is it twice it will trigger to exit the editing of a row. I always have a datagrid where the user can edit a row but right now the user cannot cancel an edit how can I get the row to exit with the cancel attribute ?
My handler
void RoutingPolicyGrid_RowEditEnded(object sender, DataGridRowEditEndedEventArgs e)
{
if (e.EditAction == DataGridEditAction.Commit)
{
}
else //DatagridEditAction.Cancel
{
}
}
Just to add here if I do it manually like the following the datagrid still triggers the RowEditEnded with the commit action this means it gets executed twice with the code below
private void RoutingPolicyGrid_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
this.RoutingPolicyGrid_RowEditEnded(sender, new DataGridRowEditEndedEventArgs(null, DataGridEditAction.Cancel));
}
By looking at the following link. The IEditable interface has to be implemented in order to be able to revert back the edition of a row and to trigger the cancel action.
http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid.canceledit%28VS.95%29.aspx