In the new version 13.4.0.58 the Xamarin.Android version of SfDataGrid is broken when used with SelectionMode.Single.
To reproduce:
1. Select one grid item
2. Select another grid item
3. Tap again on the second grid item
4. The selection cannot be altered anymore, tapping on other rows does not change anything.
See example code below:
using Android.App;
using Android.Widget;
using Android.OS;
using System.Collections.ObjectModel;
using Syncfusion.SfDataGrid;
using Android.Views;
namespace App1
{
[Activity(Label = "App1", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
var view = FindViewById<LinearLayout>(Resource.Id.linearLayout1);
var data = new MyDataCollection();
SfDataGrid grid = new SfDataGrid(this);
grid.ItemsSource = data.MyData;
grid.SelectionMode = SelectionMode.Single;
view.AddView(grid,800,500);
}
}
public class MyDataCollection
{
ObservableCollection<MyDataClass> myData;
public ObservableCollection<MyDataClass> MyData
{
get { return myData; }
set { myData = value; }
}
public MyDataCollection()
{
myData = new ObservableCollection<MyDataClass>();
GenerateData();
}
void GenerateData()
{
for (int i = 1; i <= 5; i++)
myData.Add(new MyDataClass(i, "Name" + 1, new string(i.ToString()[0], 5), "Town" + i));
}
}
public class MyDataClass
{
int id;
string name;
string zip;
string town;
public int Id
{
get { return id; }
set { id = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
public string Zip
{
get { return zip; }
set { zip = value; }
}
public string Town
{
get { return town; }
set { town = value; }
}
public MyDataClass(int id, string name, string zip, string town)
{
this.id = id;
this.name = name;
this.zip = zip;
this.town = town;
}
}
}The XML file:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#255"
android:minWidth="25px"
android:minHeight="25px">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
android:id="@+id/linearLayout1" />
</FrameLayout>