private double? scrollOffset;
private void scrollViewerHome_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (scrollOffset.HasValue)
{
scrollViewerHome.ScrollToVerticalOffset(scrollOffset.Value);
scrollOffset = null; // No need to set the scroll offset again
}
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
State["ScrollOffsetKey"] = scrollViewerHome.VerticalOffset;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (State.ContainsKey("ScrollOffsetKey"))
{
scrollOffset = (double)State["ScrollOffsetKey"];
}
}
private void scrollViewerHome_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (scrollOffset.HasValue)
{
scrollViewerHome.ScrollToVerticalOffset(scrollOffset.Value);
scrollOffset = null; // No need to set the scroll offset again
}
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
State["ScrollOffsetKey"] = scrollViewerHome.VerticalOffset;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (State.ContainsKey("ScrollOffsetKey"))
{
scrollOffset = (double)State["ScrollOffsetKey"];
}
}