How to: Check a SwitchColumn by a Single Tap

This example illustrates how to implement the SwitchColumn value changing using a single tap (not a usual approach with opening an edit row). To add this functionality, follow the steps below.

  1. Set the GridControl.AllowEditRows property to false to disable the grid's editing row feature.
  2. Create an object (Data in this example) that implements the INotifyPropertyChanged interface and has a Boolean property (IsSelected in this example) that notifies a GridControl whether or not a corresponding cell is selected.
  3. Assign the DevExpress.Mobile.Core.Containers.BindingList<T> (T is the Data type in this example) collection to the GridControl.ItemsSource property.
  4. Subscribe to the GridControl.RowTap event and use its handler to change the Boolean property's (from step 2) value.
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        xmlns:local="clr-namespace:DXSample"
        x:Class="DXSample.DXSamplePage"
        xmlns:dxg="clr-namespace:DevExpress.Mobile.DataGrid;assembly=DevExpress.Mobile.Grid.v16.2">

    <dxg:GridControl AllowEditRows="false" x:Name="grid">
        <dxg:GridControl.Columns>
            <dxg:SwitchColumn FieldName="IsSelected" />
            <dxg:TextColumn FieldName="Text"/>
        </dxg:GridControl.Columns>
    </dxg:GridControl>
</ContentPage>