Scroll the selected item into view
You can achieve your requirement by using the ProcessSelectedItemChanged method in the GridSelectionController class.This method handles the selection and you can able to view the selected item in the Grid.
You can customize the GridSelectionController class and set the instance of that customized GridSelectionControllerExt class to datagrid.SelectionController property.
C#
|
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); }
|
XAML
|
<Syncfusion:SfDataGrid x:Name="datagrid" ColumnSizer="Star" AutoGenerateColumns="True" NavigationMode="Cell" AllowEditing="True" ItemsSource="{Binding OrderInfoCollection }" |
Sample: http://www.syncfusion.com/downloads/support/forum/121515/ze/WPF431200764
Please let us know if you have any further assistance.
Regards
Ayyanar
Thank you for the update.
We are glad that your issue has been fixed.
Please let us know if you need any other assistance.
Regards,
Ashwini P.
|
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)); |
- 5 Replies
- 5 Participants
-
SC sabrina c.
- Dec 22, 2015 05:18 PM UTC
- Mar 1, 2019 12:53 PM UTC