Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
147857 | Sep 25,2019 09:54 PM UTC | Dec 30,2020 10:24 AM UTC | WPF | 5 |
![]() |
Tags: SfDataGrid |
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;
}
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.