private SfDataGrid _dataGrid;
private ViewModel _viewModel;
private SfPopupLayout popup;
private System.Drawing.Point point;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
this.SetContentView(Resource.Layout.DataGridLayout);
point = new System.Drawing.Point();
popup = new SfPopupLayout(this);
popup.PopupView.ShowFooter = false;
popup.PopupView.ShowHeader = false;
popup.PopupView.HeightRequest = 200;
popup.PopupView.WidthRequest = 200;
popup.PopupView.PopupStyle.OverlayColor = Color.Transparent;
popup.ShowOverlayAlways = false;
_viewModel = new ViewModel();
_dataGrid = FindViewById<SfDataGrid>(Resource.Id.sfDataGrid1);
_dataGrid.AutoGenerateColumns = true;
_dataGrid.ItemsSource = _viewModel.OrdersInfo;
_dataGrid.AllowResizingColumn = true;
_dataGrid.AllowSorting = true;
_dataGrid.SortColumnDescriptions.Add(new SortColumnDescription()
{
ColumnName = "OrderID",
SortDirection = ListSortDirection.Descending
});
_dataGrid.GridLongPressed += _dataGrid_GridLongPressed;
}
private void _dataGrid_GridLongPressed(object sender, GridLongPressedEventArgs e)
{
point = SfDataGridHelpers.RowColumnIndexToPoint(_dataGrid, e.RowColumnIndex);
int x = point.X;
int y = point.Y;
popup.Show(x, y);
} |