I have to come back to this same problem once again.
We have still problems to get scroll bars correctly synchronized when UseChartVirtualization="True"
It do not happen all the time but when it happens it causes a lot of troubles for the software users.
And we have to use Virtualization because of its efficiency.
we tried to correct this as you succeeded earlier.
But as you see SetVerticalScrollPercent fails to set vertical scroll bar.
It is 100 after set

??
Here is what we do:
Private Function GetVerticalScrollPercent() As Double
Dim p As AutomationPeer
If ResourceFlexyGantt.UseChartVirtualization Then
p = If(FrameworkElementAutomationPeer.FromElement(ResourceFlexyGantt.GanttChart.VerticalScrollViewerElement), FrameworkElementAutomationPeer.CreatePeerForElement(ResourceFlexyGantt.GanttChart.VerticalScrollViewerElement))
Else
p = If(FrameworkElementAutomationPeer.FromElement(ResourceFlexyGantt.GanttChart.VerticalScrollViewerElement), FrameworkElementAutomationPeer.CreatePeerForElement(ResourceFlexyGantt.GanttChart.VerticalScrollViewerElement))
End If
Dim chartScrollProvider = TryCast(p.GetPattern(PatternInterface.Scroll), IScrollProvider)
Return chartScrollProvider.VerticalScrollPercent
End Function
Private Sub SetVerticalScrollPercent(grid As DataGrid, direction As ScrollDirection, vp As Double)
' Get the scroll provider of the grid.
Dim p1 As AutomationPeer = If(FrameworkElementAutomationPeer.FromElement(grid), FrameworkElementAutomationPeer.CreatePeerForElement(grid))
Dim scrollProvider As IScrollProvider = TryCast(p1.GetPattern(PatternInterface.Scroll), IScrollProvider)
' Scroll.
Select Case direction
Case ScrollDirection.Up, ScrollDirection.Down
If scrollProvider.VerticallyScrollable Then
scrollProvider.SetScrollPercent(System.Windows.Automation.ScrollPatternIdentifiers.NoScroll, vp)
End If
Exit Select
Case ScrollDirection.Left, ScrollDirection.Right
If scrollProvider.HorizontallyScrollable Then
scrollProvider.SetScrollPercent(vp, System.Windows.Automation.ScrollPatternIdentifiers.NoScroll)
End If
Exit Select
End Select
End Sub
Private Async Sub FillFlexyGantt() ' get data
vp = Me.GetVerticalScrollPercent()
.......
read data from Sql Server
ResevationsItemSource = GetReservations(....
' ResevationsItemSource = binding collecton
.......
' Check and set the scroll percent to the grid.
Do While ResourceFlexyGantt.FlexyTable.AsControl.IsEnabled = False
Await System.Threading.Tasks.Task.Run( _
Sub()
System.Threading.Thread.Sleep(100) ' Give time for view to be updated before resetting scroll bar
End Sub)
Loop
Dim vp2 As Double = GetVerticalScrollPercent()
If vp2 <> vp Then
If vp > 0 And ResourceFlexyGantt.FlexyTable.AsControl.IsEnabled = True Then
Dim grid As DataGrid = DirectCast(ResourceFlexyGantt.FlexyTable.AsControl, DataGrid)
SetVerticalScrollPercent(grid, ScrollDirection.Up, vp)
End If
End If
System.Diagnostics.Debug.WriteLine("Scroll before: " & vp.ToString & " After: " & vp2.ToString)
...........
End Sub
Scroll before: 53.3333333333333 After: 100
Scroll before: 56.25 After: 100
Scroll before: 56.25 After: 100
Scroll before: 53.3333333333333 After: 100