this.dataGrid.SelectionController = new GridSelectionControllerExt(this.dataGrid);
internal class GridSelectionControllerExt : GridSelectionController
{
public GridSelectionControllerExt(SfDataGrid datagrid) : base(datagrid)
{
}
private bool isSelectedRow = false;
int prevSelectionIndex = 0;
protected override void ProcessPointerPressed(PointerRoutedEventArgs args, RowColumnIndex rowColumnIndex)
{
base.ProcessPointerPressed(args, rowColumnIndex);
var currentRowIndex = rowColumnIndex.RowIndex;
if (currentRowIndex != prevSelectionIndex)
{
if (!isSelectedRow)
isSelectedRow = true;
else
isSelectedRow = false;
prevSelectionIndex = currentRowIndex;
(this.DataGrid.DataContext as UserInfoViewModel).EditButtonVisible = true;
}
else
{
this.DataGrid.SelectedItems.Clear();
isSelectedRow = false;
(this.DataGrid.DataContext as UserInfoViewModel).EditButtonVisible = false;
}
}
}
|