I finally managed to sync two ListViews I had together so I'm able to scroll both at the same time.
I used the GetScrollViewer()
method from this post and the sync method from this post.
Now I want to be able to scroll either of the two ListViews but when I just add another event like this:
private void SyncScrollViewers()
{
var scrollViewer1 = ListViewOne.GetScrollViewer();
var scrollViewer2 = ListViewTwo.GetScrollViewer();
if (scrollViewer1 == null || scrollViewer2 == null) return;
scrollViewer1.ViewChanged += (s, e) =>
{
scrollViewer2.ChangeView(null, scrollViewer1.VerticalOffset, null, false);
};
scrollViewer2.ViewChanged += (s, e) =>
{
scrollViewer1.ChangeView(null, scrollViewer2.VerticalOffset, null, false);
};
}
It just keeps repeating the events.
When I scroll ScrollViewer1
it fires the scroll event for ScrollViewer2
and when that one scrolls it fires the event for ScrollViewer1
again.
Which makes scrolling the ListViews a rather wobbly sight.
Is there any way to stop the second event of firing when the sender is either ScrollViewer1
or ScrollViewer2
?