New to Telerik UI for Xamarin? Download free 30-day trial

Different functionalities on CellTap and CellDoubleTap in DataGrid


Product Version 2021.2.512.1
Product DataGrid for Xamarin.Forms


This how-to article will showw you how to add separate functionalities on cell tap and cell double tap.


RadDataGrid provides CellTap and CellDoubleTap commands that can be used to easily achieve the wanted result in three steps:

  • You have to create a class that inherits from DataGridCommand. More information about DataGrid commands.

  • Then implement your custom logic into the Execute method and set this.Owner.CommandService.ExecuteDefaultCommand to DataGridCommandId.CellTap or DataGridCommandId.CellDoubleTap.

using System;
using Telerik.XamarinForms.DataGrid;
using Telerik.XamarinForms.DataGrid.Commands;
using Xamarin.Forms;

namespace App9
    public class CellTapUserCommand : DataGridCommand
        public CellTapUserCommand()
            Id = DataGridCommandId.CellTap;

        public override bool CanExecute(object parameter)
            return parameter is DataGridCellInfo;

        public override void Execute(object parameter)
            var info = (DataGridCellInfo)parameter;

            Device.StartTimer(TimeSpan.FromMilliseconds(50), () =>
                if (!DoubleCellTapUserCommand.isDoubleTap)
                    this.Owner.CommandService.ExecuteDefaultCommand(DataGridCommandId.CellTap, parameter);
                    DoubleCellTapUserCommand.isDoubleTap = false;

                return false;

    public class DoubleCellTapUserCommand : DataGridCommand
        internal static bool isDoubleTap;

        public DoubleCellTapUserCommand()
            this.Id = DataGridCommandId.CellDoubleTap;

        public override void Execute(object parameter)
            isDoubleTap = true;
            Application.Current.MainPage.DisplayAlert("Double Tap", "Double tap OK?", "OK");
            this.Owner.CommandService.ExecuteDefaultCommand(DataGridCommandId.CellDoubleTap, parameter);
  • Add the commands to the DataGrid.Commands:
<ContentPage xmlns=""
    <grid:RadDataGrid x:Name="grid"
                      ItemsSource="{Binding Items}"
            <grid:DataGridTextColumn PropertyName="Title"/>
            <grid:DataGridNumericalColumn PropertyName="Author"/>

Set the BindingContext in code-behind:

public partial class MainPage : ContentPage
    public MainPage()

        this.BindingContext = new ViewModel();

Used ViewModel and Business Model:

public class Book
    public string Title { get; set; }

    public string Author { get; set; }

public class ViewModel
    public ObservableCollection<Book> Items { get; set; }

    public ViewModel()
        this.Items = new ObservableCollection<Book>()
            new Book{ Title = "The Fault in Our Stars ",  Author = "John Green"},
            new Book{ Title = "Divergent",  Author = "Veronica Roth"},
            new Book{ Title = "Gone Girl",  Author = "Gillian Flynn"},
            new Book{ Title = "Clockwork Angel",  Author = "Cassandra Clare"},
            new Book{ Title = "The Martian",  Author = "Andy Weir"},
            new Book{ Title = "Ready Player One",  Author = "Ernest Cline"},
            new Book{ Title = "The Lost Hero",  Author = "Rick Riordan"},
            new Book{ Title = "All the Light We Cannot See",  Author = "Anthony Doerr"},
            new Book{ Title = "Cinder",  Author = "Marissa Meyer"},
            new Book{ Title = "Me Before You",  Author = "Jojo Moyes"},
            new Book{ Title = "The Night Circus",  Author = "Erin Morgenstern"},
In this article