How to cache a page in Windows Phone 8.1

Previously, in applications, Windows Phone 8.0we could navigate deeper into the same page as follows:

NavigationService.Navigate(new Uri("/SamePage.xaml", UriKind.Relative));

The page was automatically cached, so after navigating back, the user was in the same position on the list when he left.

But in Windows Phone Store Appswe go deeper into the same page as follows:

Frame.Navigate(typeof(SamePage), id);

But after navigating through it, it loads the data again, so if the user is in the middle of a long list, now he is on top:

private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
{
    // TODO: Create an appropriate data model for your problem domain to replace the sample data.
    var group = await SampleDataSource.GetGroupAsync((string)e.NavigationParameter);
    this.DefaultViewModel["Group"] = group;
}

How to cache the page in the same way as it was done earlier, so the user will be in the same position in the list where he left?

(I turned on Windows applications because they have been familiar with it for a longer time).

+4
2

    public MainPage()
    {
       this.InitializeComponent();
       this.NavigationCacheMode = NavigationCacheMode.Required;
    }
+6

App.cs RootFrame.CacheSize, , . , , reset datacontext NavigationHelper_LoadState - , , .

0

Source: https://habr.com/ru/post/1538986/


All Articles