this.datagrid.SelectionController = new GridSelectionControllerExt(datagrid); public class GridSelectionControllerExt : GridSelectionController { public GridSelectionControllerExt(SfDataGrid datagrid) : base(datagrid) { } protected override void ProcessSelectedItemChanged(SelectionPropertyChangedHandlerArgs handle) { base.ProcessSelectedItemChanged(handle); if (handle.NewValue != null) this.DataGrid.ScrollInView(this.CurrentCellManager.CurrentRowColumnIndex); }
|
<Syncfusion:SfDataGrid x:Name="datagrid" ColumnSizer="Star" AutoGenerateColumns="True" NavigationMode="Cell" AllowEditing="True" ItemsSource="{Binding OrderInfoCollection }" |
int rowIndex = this.CurrentCellManager.CurrentRowColumnIndex.RowIndex;
int columnIndex = this.CurrentCellManager.CurrentRowColumnIndex.ColumnIndex;
int scrollRowIndex = (rowIndex + this.DataGrid.GetVisualContainer().ScrollRows.LastBodyVisibleLineIndex - 1) <= this.DataGrid.GetVisualContainer().ScrollRows.LineCount ? (rowIndex + this.DataGrid.GetVisualContainer().ScrollRows.LastBodyVisibleLineIndex - 1) : 0;
if (scrollRowIndex != 0)
this.DataGrid.ScrollInView(new RowColumnIndex(scrollRowIndex, columnIndex));
else
this.DataGrid.ScrollInView(new RowColumnIndex(this.DataGrid.GetVisualContainer().ScrollRows.LineCount - 1, columnIndex)); |