你的位置:首页 > 操作系统

[操作系统]WP 8.1 中挂起时页面数据保存方式


1.保存到Applicaion Data配置信息中:

保存:

private void testTB_TextChanged(object sender, TextChangedEventArgs e){  ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;  localSettings.Values["value"] = testTB.Text;}

读取:

private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e){  ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;  if (localSettings.Values.ContainsKey("value"))  {    testTB.Text = localSettings.Values["value"].ToString();  }}

 

2.放到页面状态中保存

保存:

private void NavigationHelper_SaveState(object sender, SaveStateEventArgs e){  e.PageState["value"] = testTB.Text;}

读取:

private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e){  if (e.PageState != null && e.PageState.ContainsKey("value"))  {    testTB.Text = e.PageState["value"].ToString();  }}