I have a problem with setting Scroll Viewer vertical scroll position (C#, Windows Store App).
I have a FlipView, which contains 2 to 5 items. Item is my own user control - Grid in Scroll Viewer. I need to change scroll position to all FlipView items, when current selected FlipView item scroll position has been changed.
In my user control I use event:
private void MyScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
{
_myPage.ChangeFlipViewItemsScrollPosition(MyScrollViewer.VerticalOffset);
}
In my page I use method:
public void ChangeFlipViewItemsScrollPosition(double verticalOffset)
{
for (int i = 0; i < MyFlipView.Items.Count; i++)
{
MyUserControl item = MyFlipView.Items[i] as MyUserControl;
if (item != null && i != MyFlipView.SelectedIndex)
{
item.MyScrollViewer.ChangeView(null, verticalOffset, null);
}
}
}
The problem is that:
For example, I have 5 items in FlipView.
When FlipView selected index is:
0 then it changes scroll position to items with index: 1 and 2;
1 then it changes scroll position to items with index: 0 and 2;
2 then it changes scroll position to items with index: 0, 1 and 3;
3 then it changes scroll position to items with index: 2 and 4;
4 then it changes scroll position to item with index: 3;
I have no idea, why it is happening. Can anyone help with this?