以前在 Windows Phone 8.0
应用程序中,我们可以通过这种方式更深入地导航到同一页面:
NavigationService.Navigate(new Uri("/SamePage.xaml", UriKind.Relative));
页面是自动缓存的,所以在返回后,用户在他离开时在列表中的相同位置。
但在 Windows Phone Store Apps
中,我们以这种方式更深入地导航到同一页面:
Frame.Navigate(typeof(SamePage), id);
但是在导航回来之后它再次加载数据所以如果用户在一个长列表的中间,现在他在顶部:
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;
}
我如何才能像以前那样缓存页面,以便用户在他离开的列表中位于相同的位置?
(我也包括了 Windows 应用程序,因为他们已经熟悉了很长时间)。
最佳答案
在你的页面构造器中你必须指定
public MainPage()
{
this.InitializeComponent();
this.NavigationCacheMode = NavigationCacheMode.Required;
}
关于c# - 如何在 Windows Phone 8.1 中缓存页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23426765/