Windows Phone 开发:数据持久化、网络编程与平台集成
数据持久化与应用执行模型
在 Windows Phone 开发中,数据持久化和应用执行模型是非常重要的部分。以下是关于数据加载和状态恢复的代码示例:
DataStore.Instance.LoadCollection<ObservableCollection<Vendor>>(
DataStore.Instance.Vendors, "Vendors");
VendorsListBox.ItemsSource = DataStore.Instance.Vendors;
// The state bag for temporary state
IDictionary<string, object> state =
PhoneApplicationService.Current.State;
// See if the bag contains the selected item
if (state.ContainsKey("Selected Item"))
{
//Set selected item on page
VendorsListBox.SelectedIndex = (int)state["Selected Item"];
//Scroll to selected item
VendorsListBox.ScrollIntoView(
VendorsListBox.Items[VendorsListBox.SelectedIndex]);
}
超级会员免费看
订阅专栏 解锁全文
4万+

被折叠的 条评论
为什么被折叠?



