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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to synchronize the scrolling of one to another in the SfDataGrid?

Platform: WPF |
Control: SfDataGrid |
.NET Framework: 4.5.1
Tags: scrollviewer

By default, it is not possible to scroll one SfDataGrid through another. However, it can be achieved by using the ScrollChanged event of the SfDataGrid. You can wire the ScrollChanged event in the loaded event of the Datagrid1 like the following code example.


void Datagrid1_Loaded(object sender, RoutedEventArgs e)
            this.Datagrid1.GetVisualContainer().ScrollOwner.ScrollChanged += ScrollOwner1_ScrollChanged;



        //ScrollChanged event of the ScrollViewer in Datagrid1.
        void ScrollOwner1_ScrollChanged(object sender, ScrollChangedEventArgs e)
            //Sets the Horizontal offset value when horizontally scrolled.
            if (e.HorizontalChange > 0 || e.HorizontalChange < 0)
            //Sets the Horizontal offset value when horizontally scrolled.
            if (e.VerticalChange > 0 || e.VerticalChange < 0)


As given in the above code example, you can set the Horizontal or Vertical offset based on its corresponding Horizontal or Vertical change while scrolling.  Likewise, you can wire the ScrollChanged event for Datagrid2 and set the Horizontal and Vertical offset.



The above code example is only applicable for the WPF platform. For WinRT, UWP refer to the following link.


Sample Links:





2X faster development

The ultimate WPF UI toolkit to boost your development speed.
You must log in to leave a comment
Zeljko Lazic
Apr 12, 2019

Is there a similar example without referring to the grids in the code behind i.e. MVVM?

Shobika Palani [Syncfusion]
Apr 15, 2019

Hi Zeljko,

We have analyzed your query to synchronize the scrolling between two SfDataGrid in MVVM pattern. And you can achieve this requirement by writing behavior for each datagrid as like below code snippet,


public class FirstSfDataGridBehavior : Behavior
        protected override void OnAttached()
            this.AssociatedObject.Loaded += AssociatedObject_Loaded;

        private void AssociatedObject_Loaded(object sender, System.Windows.RoutedEventArgs e)
            this.AssociatedObject.GetVisualContainer().ScrollOwner.ScrollChanged += ScrollOwner_ScrollChanged;

        private void ScrollOwner_ScrollChanged(object sender, System.Windows.Controls.ScrollChangedEventArgs e)
            SfDataGrid otherDataGrid = Application.Current.MainWindow.FindName("Datagrid2") as SfDataGrid;

            //Set the Vertical offset for Grid1 and Grid2 when we Vertically scroll the Grid
            if (e.HorizontalChange > 0 || e.HorizontalChange < 0)

            //Set the Vertical offset for Grid1 and Grid2 when we Vertically scroll the Grid
            if (e.VerticalChange > 0 || e.VerticalChange < 0)

Please find sample for the same from the below link Sample Link: WPF

Please let us know, if you need any further assistance on this.

Regards, Shobika.

Thierry Delucinges
Oct 03, 2019


Same problem, I tried with the behavior version but on AssociatedObject_Loaded, this.AssociatedObject.GetVisualContainer() return null… I've also set ScrollViewer.HorizontalScrollBarVisibility="Visible" in xaml in case of… but… Regards.

Mohanram Anbukkarasu [Syncfusion]
Oct 07, 2019

Hi Thierry,

Thanks for your update.

We have checked the reported case in our sample. But unfortunately we are unable to reproduce the reported issue in our end. Please ensure whether you have any other customization in your sample and let us know if any. It will be helpful for us to find the cause for the issue and provide a proper solution.

Regards, Mohanram A.

Jun 20, 2022

the method GetVisualContainer() does not appear to be available with the latest winform sfDataGrid.

Vijayarasan Sivanandham [Syncfusion]
Jun 21, 2022

Hi Tim,

The GetVisualContainer helper method is contained in knowledge base documentation sample links containing platform only (ex:WPF,UWP). WinForms SfDataGrid does not contain the GetVisualContainer helper method.

However, your requirement to synchronize the scrolling of one to another in the SfDataGrid can be achieved by using the WindowScrolled event in SfDataGrid.TableControl. Please refer to the below code snippet,

//WindowScrolled event wired for first datagrid1
sfDataGrid1.TableControl.WindowScrolled += OnWindowScrolled;

//WindowScrolled event occurs after the window has been scrolled in sfDataGrid1.
private void OnWindowScrolled(object sender, ScrollWindowEventArgs e)
            //here sync the Second DataGrid scrolling based on first SfDataGrid

            if (e.XAmount < 0 || e.XAmount > 0)
                //Set the Horizontal offset for sfDataGrid2 and sfDataGrid1 when we Horizontally scroll the sfDataGrid1

            //Set the Vertical offset for sfDataGrid2 and sfDataGrid1 when we Vertically scroll the sfDataGrid1
            if (e.YAmount < 0 || e.YAmount > 0)

Sample Link: WF

UG Link: Handling events

Please let us know if you have any concerns in this.

Regards, Vijayarasan S

Please sign in to access our KB

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

Up arrow icon

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

Live Chat Icon For mobile