Save scroll state in Windows Phone 8.1 when user navigate between pages

scrollviewer, windows-phone-8.1

Solution

On the page where you use the hub, set the navigation cache mode in constructor:

this.NavigationCacheMode = NavigationCacheMode.Enabled;

or in XAML:

<Page
    x:Class="App.HubPage"
    ....
    xmlns:data="using:App.Data"
    NavigationCacheMode="Enabled"
    ....

Problem

I navigate between pages with Navigation Helper class which VS 2013 added when solution created, But scroll state most of controls (Like Pivot, Hub) does not saved like in Windows Phone 8.x Silverlight. What should I do for implement this behaviour? Should I handle scrolling state by myself and restore scroll when i go back in visited page? Thanks. UPDATE1: I need save selected pivot/hub item etc, when i go back to page. UPDATE2: ``` void navigationHelper_SaveState(obj sender,SaveStateEventArgs e) { e.PageState["SelectedSection"] = MainHub.SectionsInView; } void navigationHelper_LoadState(obj sender,LoadStateEventArgs e) { if (e.PageState != null) { var sections = e.PageState["SelectedSection"] as IList<HubSection>; if (sections != null && sections.Any()) MainHub.ScrollToSection(sections[0]); } } ```

Original source