public void LoadState() { // load a setting that is local to the device ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; Windows.Storage.ApplicationDataCompositeValue composite = (ApplicationDataCompositeValue)localSettings.Values["Backup"]; if (composite != null) { ObservableCollection <CustomDataObject> LoadedItems = new ObservableCollection <CustomDataObject>(); try { foreach (var item in composite) { System.Diagnostics.Debug.WriteLine(item); var splitItem = item.Value.ToString().Split(","); var customObject = new CustomDataObject() { ImageLocation = item.Key, Title = splitItem[0], Receiver = splitItem[1], Steals = Int32.Parse(splitItem[2]), Giver = splitItem[3] }; LoadedItems.Add(customObject); } if (composite.Count == 0) { LoadedItems = null; } } catch (Exception e) { LoadedItems = null; } Items = LoadedItems; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (Items == null) { List <CustomDataObject> tempList = CustomDataObject.GetDataObjects(); Items = new ObservableCollection <CustomDataObject>(tempList); } BasicGridView.ItemsSource = Items; Players = new List <String>(); foreach (var item in Items) { Players.Add(item.Giver); } var tempList2 = Players.OrderBy(a => Guid.NewGuid()).ToList(); Players = tempList2; }