We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Scroll the selected item into view

Thread ID:





121515 Dec 22,2015 05:18 PM UTC Mar 1,2019 12:53 PM UTC WPF 5
Tags: SfDataGrid
sabrina c.
Asked On December 22, 2015 05:18 PM UTC

Hi, I've found something on this subject but they are specific cases not simple as mine so I ask:

I have a grid where I programmatically add a record, the added record is then selected using the ViewModel Binding.

My Grid has:

ItemsSource = "{Binding MyElementsCollection}"
SelectedItem = "{Binding MySelectedItem}

When I set the selected item from code, It works perfectly except for the fact that if the selected item is not inside the visible part of the grid it remains invisible.

So, I wanted to know if there is a way to do something like:


thank you in advance

Ayyanar Sasi Kumar Jeyaraj [Syncfusion]
Replied On December 23, 2015 12:38 PM UTC

Hi Sabrina,

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.

this.datagrid.SelectionController = new GridSelectionControllerExt(datagrid); 

public class GridSelectionControllerExt : GridSelectionController


        public GridSelectionControllerExt(SfDataGrid datagrid)

            : base(datagrid)



        protected override void ProcessSelectedItemChanged(SelectionPropertyChangedHandlerArgs handle)



            if (handle.NewValue != null)





<Syncfusion:SfDataGrid x:Name="datagrid" 





                                       ItemsSource="{Binding OrderInfoCollection }"
                                       SelectedItem="{Binding MySelectedItem,Mode=TwoWay}">

Sample: http://www.syncfusion.com/downloads/support/forum/121515/ze/WPF431200764

Please let us know if you have any further assistance.


sabrina c.
Replied On December 23, 2015 02:05 PM UTC

It Works perfectly, Thank You very much

Ashwini Paranthaman [Syncfusion]
Replied On December 24, 2015 09:28 AM UTC

Hi Sabrina,
Thank you for the update.
We are glad that your issue has been fixed.
Please let us know if you need any other assistance.
Ashwini P.

Ondrej Svoboda
Replied On February 28, 2019 11:06 AM UTC

Hi, this works nice, except one detail. The selected record is always the last row in visible area. Couldn't this be changed so it is the first row?

Mohanram Anbukkarasu [Syncfusion]
Replied On March 1, 2019 12:53 PM UTC

Hi Ondrej, 
Thanks for your update. 
SfDataGrid doesn't have direct support to achieve this requirement. However we can provide a workaround to achieve this by changing the RowIndex value passed to the ScrollInView method based on the number of visible rows. Please refer the following code example. 
Code example 
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)); 
    this.DataGrid.ScrollInView(new RowColumnIndex(this.DataGrid.GetVisualContainer().ScrollRows.LineCount - 1, columnIndex)); 
Please let us know if the given solution doesn't meet your requirement. 
Mohanram A. 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon