this.datagrid.SelectionController = new GridSelectionControllerExt(datagrid);
public class GridSelectionControllerExt : GridSelectionController
{
public GridSelectionControllerExt(SfDataGrid dataGrid)
: base(dataGrid)
{ }
protected override void ProcessPointerPressed(MouseButtonEventArgs args, RowColumnIndex rowColumnIndex)
{
if (args.ChangedButton == MouseButton.Right)
{
args.Handled = true;
}
else
base.ProcessPointerPressed(args, rowColumnIndex);
}
} |
public class GridSelectionControllerExt : GridSelectionController
{
public GridSelectionControllerExt(SfDataGrid dataGrid)
: base(dataGrid)
{ }
protected override void ProcessOnTapped(MouseButtonEventArgs e, RowColumnIndex currentRowColumnIndex)
{
if (e.ChangedButton == MouseButton.Left)
base.ProcessOnTapped(e, currentRowColumnIndex);
else
e.Handled = true;
}
} |
public class SfDataGridBehavior:Behavior<SfDataGrid>
{
SfDataGrid dataGrid = null;
bool isRighClickButtonEnabled = false;
protected override void OnAttached()
{
base.OnAttached();
this.dataGrid = this.AssociatedObject as SfDataGrid;
this.dataGrid.CellTapped += DataGrid_CellTapped;
this.dataGrid.CurrentCellBeginEdit += DataGrid_CurrentCellBeginEdit;
}
private void DataGrid_CurrentCellBeginEdit(object sender, CurrentCellBeginEditEventArgs e)
{
if (isRighClickButtonEnabled)
e.Cancel = true;
}
private void DataGrid_CellTapped(object sender, GridCellTappedEventArgs e)
{
if(e.ChangedButton == System.Windows.Input.MouseButton.Right)
{
isRighClickButtonEnabled = true;
}
else
{
isRighClickButtonEnabled = false;
}
}
} |