New to Telerik UI for .NET MAUI? Start a free 30-day trial

Cell Info on Right Click in DataGrid


Version Product Author
5.1.0 Telerik UI for .NET MAUI Chart Dobrinka Yordanova


This how-to article describes how to get the cell info on a right click in the Telerik UI for .NET MAUI DataGrid control.


1. Add DataGrid to the Page:

    <telerik:RadDataGrid x:Name="dataGrid" />

2. Add Sample data to the RadDataGrid.ItemsSource:

this.dataGrid.ItemsSource = new List<Data>
    new Data { Country = "India", Capital = "New Delhi"},
    new Data { Country = "South Africa", Capital = "Cape Town"},
    new Data { Country = "Nigeria", Capital = "Abuja" },
    new Data { Country = "Singapore", Capital = "Singapore" }

3. Add the Data class:

public class Data
    public string Country { get; set; }
    public string Capital { get; set; }

4. Add TapGestureRecognizer for right-click and get the position of the internal ScrollView in the DataGrid on right click and use the DataGrid HitTestService.CellInfoFromPoint() method , to get the cell info for the concrete position.

RadScrollView sv = null;
foreach (var child in this.dataGrid)
    if (child is RadScrollView)
        sv = child as RadScrollView;

var content = sv.Content;

var tap = new TapGestureRecognizer()
    Buttons = ButtonsMask.Secondary

tap.Tapped += (s, e) =>
    var position = e.GetPosition(content);
    var hitTestService = this.dataGrid.HitTestService;
    var cellInfo = hitTestService.CellInfoFromPoint(position.Value);

    // sample visualization the data in the cell when right-click
    App.Current.MainPage.DisplayAlert("Right click on",""+cellInfo.Value,"ОК");

5. Finally, add this gesture to the DataGrid GestureRecognizers.

In this article