New to Telerik UI for WinUI? Start a free 30-day trial
CancelEdit Command
Updated on Mar 10, 2026
The CanEdit command provides an entry point just before the editing is canceled.
Execution Parameter
The execution parameter is of type EditContext that exposes the following properties:
CellInfo—Gets the cell information associated with the operation.TriggerAction—Gets theSourceTriggerActionvalue that triggered the operation.Parameter—Gets an optional parameter holding additional information associated with the operation.
Custom CancelEdit Command
The following examples show how to create a class that inherits from the DataGridCommand and add it to the Commands collection.
Create a Custom CancelEdit Command
C#
public class CustomCancelEditCommand : DataGridCommand
{
public CustomCancelEditCommand()
{
this.Id = CommandId.CancelEdit;
}
public override bool CanExecute(object parameter)
{
return true;
}
public override void Execute(object parameter)
{
var context = parameter as EditContext;
// put your custom logic here
// Executes the default implementation of this command
this.Owner.CommandService.ExecuteDefaultCommand(CommandId.CancelEdit, context);
}
}
Add the Custom Command to the Commands Collection
XAML
<Grid xmlns:grid="using:Telerik.UI.Xaml.Controls.Grid">
<grid:RadDataGrid Width="600" Height="460" x:Name="grid" Hold>
<grid:RadDataGrid.Commands>
<local:CustomCancelEditCommand/>
</grid:RadDataGrid.Commands>
</grid:RadDataGrid>
</Grid>