1.保存到Applicaion Data配置信息中:
保存:
privatevoid testTB_TextChanged(object sender, TextChangedEventArgs e) { ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; localSettings.Values["value"] = testTB.Text; }
读取:
privatevoid NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; if (localSettings.Values.ContainsKey("value")) { testTB.Text = localSettings.Values["value"].ToString(); } }
2.放到页面状态中保存
保存:
privatevoid NavigationHelper_SaveState(object sender, SaveStateEventArgs e) { e.PageState["value"] = testTB.Text; }
读取:
privatevoid NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.PageState != null && e.PageState.ContainsKey("value")) { testTB.Text = e.PageState["value"].ToString(); } }