WP 8.1 中挂起时页面数据保存方式

2015-12-15 08:01:14来源:cnblogs.com作者:AD1988人点击

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();    }}

 

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台