That was the case! I tried to initialize it too early.
I did it in constructor, when it was initialized yet.
If someone needs solution how to synchronize data grids (it doesn't matter if this is vanilla DataGrid or DevExpress GridControl or mix of them) to show the same data when you are horizontally scrolling and you have more columns then you can show then here is the solution:
In your constructor:
mainDataGrid.Loaded += (sender, args) =>
{
ScrollViewer sv = mainDataGrid.FindVisualTreeChild<ScrollViewer>();
if (sv != null)
sv.ScrollChanged += DataGridScrollChanged;
};
Add the event handler for ScrollChanged event:
private void DataGridScrollChanged(object sender, ScrollChangedEventArgs e)
{
if (e.HorizontalChange == 0.0f)
return;
ScrollViewer sv = dependentDataGrid1.FindVisualTreeChild<ScrollViewer>();
if (sv != null)
sv.ScrollToHorizontalOffset(e.HorizontalOffset);
sv = dependentDataGrid2.FindVisualTreeChild<ScrollViewer>();
if (sv != null)
sv.ScrollToHorizontalOffset(e.HorizontalOffset);
}