//Local variable to store the datagrid instance
static object value;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
if (dataGrid == null)
{
if (value != null)
dataGrid = value as SfDataGrid;
else
{
dataGrid = new SfDataGrid(BaseContext);
dataGrid.ItemsSource = viewModel.OrdersInfo;
dataGrid.AutoGenerateColumns = true;
dataGrid.SelectionMode = SelectionMode.Single;
dataGrid.GroupColumnDescriptions.Add(new GroupColumnDescription() { ColumnName = "CustomerID" });
}
}
}
protected override void OnPause()
{
base.OnPause();
//Store the old instance of SfDataGrid whenever the screen rotates.
value = dataGrid;
} |