I am following the sample for the swipe delete but in the sample the grid is restricted to be the same width as the screen andsfGrid.AutoGenerateColumns = false;
I want to Autogenerate about 7 columns and so I have an AutoGenerateColumns handler. When the grid is rendered it is wider than the screen and the user can slide it to see all columns to the right. But when the user slides the grid all the way to the right and then slides a row further to the right the row does slide but the "Delete and "Undo" view (sfGrid.LeftSwipeView) is not displayed but the row is deleted from the grid. The sfGrid.RightSwipeView works as expected.
If I do not set the sfGrid.LeftSwipeView then the app crashes when the sfGrid.RightSwipeView swipe event is triggered.
This is difficult to explain but hopefully you understand what I am trying to achieve. I want the "Delete" and "Undo" view to be displayed for both left and right row swipes and I want to size my columns such that they will extend past the width of the screen.
public override Android.Views.View GetSampleContent(Android.Content.Context context)
{
FrameLayout frame = new FrameLayout(context);
linear = new LinearLayout(context);
linear.Orientation = Orientation.Horizontal;
ImageView swipeViewImage = new ImageView(context);
swipeViewImage.SetImageResource(Resource.Drawable.Undo);
swipeViewImage.SetBackgroundColor(Color.ParseColor("#1AAA87"));
swipeViewImage.Click += swipeViewImage_Click;
TextView swipeViewText = new TextView(context);
swipeViewText.Text = "Delete";
swipeViewText.Gravity = GravityFlags.Center;
swipeViewText.SetTextColor(Color.White);
swipeViewText.SetBackgroundColor(Color.ParseColor("#1AAA87"));
viewModel = new SwipingViewModel();
viewModel.SetRowstoGenerate(100);
sfGrid = new SfDataGrid(context);
sfGrid.GridStyle = new Dark();
//sfGrid.AutoGenerateColumns = false;
sfGrid.ItemsSource = (viewModel.OrdersInfo);
sfGrid.AllowSwiping = true;
//sfGrid.ColumnSizer = ColumnSizer.Star;
DisplayMetrics metrics = context.Resources.DisplayMetrics;
int width = metrics.WidthPixels;
sfGrid.MaxSwipeOffset = width;
swipe = new SwipeView(context);
linear.AddView(swipeViewText, sfGrid.MaxSwipeOffset / 2, (int)sfGrid.RowHeight);
linear.AddView(swipeViewImage, sfGrid.MaxSwipeOffset / 2, (int)sfGrid.RowHeight);
swipe.AddView(linear);
sfGrid.LeftSwipeView = swipe;
sfGrid.RightSwipeView = swipe;
sfGrid.SwipeEnded += sfGrid_SwipeEnded;
sfGrid.SwipeStarted += sfGrid_SwipeStarted;
sfGrid.AutoGeneratingColumn += DataGrid_AutoGeneratingColumn;
GridTextColumn CustomerID = new GridTextColumn();
CustomerID.MappingName = "CustomerID";
CustomerID.HeaderText = "Customer ID";
GridTextColumn OrderID = new GridTextColumn();
OrderID.MappingName = "OrderID";
OrderID.HeaderText = "Order ID";
GridTextColumn EmployeeID = new GridTextColumn();
EmployeeID.MappingName = "EmployeeID";
EmployeeID.HeaderText = "Employee ID";
GridTextColumn Name = new GridTextColumn();
Name.MappingName = "FirstName";
Name.HeaderText = "Name";
GridTextColumn ShipCity = new GridTextColumn();
ShipCity.MappingName = "ShipCity";
ShipCity.HeaderText = "Ship City";
GridTextColumn ShipCountry = new GridTextColumn();
ShipCountry.MappingName = "ShipCountry";
ShipCountry.HeaderText = "Ship Country";
GridTextColumn Freight = new GridTextColumn();
Freight.MappingName = "Freight";
Freight.HeaderText = "Freight";
sfGrid.Columns.Add(OrderID);
sfGrid.Columns.Add(CustomerID);
sfGrid.Columns.Add(EmployeeID);
sfGrid.Columns.Add(Name);
sfGrid.Columns.Add(ShipCity);
sfGrid.Columns.Add(ShipCountry);
sfGrid.Columns.Add(Freight);
frame.AddView(sfGrid);
return frame;
}
Any assistance appreciated.