New to Telerik UI for .NET MAUIStart a free 30-day trial

Changing Edit Mode Behavior in DataGrid for MAUI

Updated over 6 months ago

Environment

PropertyValue
ProductDataGrid for MAUI
Version6.7.0

Description

I want to modify the behavior of the RadDataGrid in my .NET Maui application so that it enters edit mode with a single click instead of requiring a double-click.

Solution

To achieve this, you can use a custom CellTap command called CellTapUserCommand. Here's an example of how to implement it:

csharp
public class CellTapUserCommand : DataGridCommand
{
    public CellTapUserCommand()
    { 
        Id = DataGridCommandId.CellTap;
    }

    public override bool CanExecute(object parameter)
    {
        return true;
    }

    public override void Execute(object parameter)
    {
        if (parameter is not DataGridCellInfo cellInfo)
        {
            return;
        }
        
        this.Owner.CommandService.ExecuteDefaultCommand(DataGridCommandId.CellDoubleTap, parameter);
    }
}

To apply the CellTapUserCommand to your RadDataGrid, add it to the Commands collection:

csharp
this.dataGrid.Commands.Add(new CellTapUserCommand());

By utilizing this custom command, you can now enter edit mode with a single click on a cell in the RadDataGrid.

See Also