wp7 tombstone墓碑机制
主要用到PhoneApplicationService类 ,也可以用独立存储保存数据吧。可能这个类里面微软做一些优化。
用法很简单,重写页面方法,在用户离开之前,将数据保存起来;在用户再一次进来时,将数据显示出来。很简单吧
//进入页面
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
PhoneApplicationService phoneService = PhoneApplicationService.Current;
IDictionary<string, object> dics = phoneService.State; //字典
if (dics.ContainsKey("day02"))
{
textBlock01.Text = dics["day02"].ToString();
}
}
//退出页面
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
PhoneApplicationService phoneService = PhoneApplicationService.Current;
IDictionary<string, object> dics = phoneService.State;
dics["day02"] = textBlock01.Text;
}