I am trying to save a list of objects that I created in isolated storage and be able to display them in a list, automatically creating a title for them. While the code is working, but as soon as I tombstone the application and run it, all my data will be saved except for the list of objects. I think that my problem may be related to how I initialize the list in the first place, or, perhaps, how I show the names. Any help is appreciated.
this code is in my app.xaml.cs application:
public partial class App : Application { public List<my_type> testList = new List<my_type>(); void loadvalues() { IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings; List<my_Type> L; if (settings.TryGetValue<List<DrinkSesh>>("Storage", out L)) { testList = L; } } void savevalues() { IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings; settings["Storage"] = testList; settings.Save(); } }
This code is on my main page to add items to the list:
(Application.Current as App).testList.Add(new my_type());
and this code is for implementing titles on the screen on another page:
public different_class() { { InitializeComponent(); for (i = 0; i < (Application.Current as App).testList.Count; i++) { CreateATextBlock((Application.Current as App).testList[i].Title_ToString(), i); } } private void CreateATextBlock(String title,int num) { testblockname = new TextBlock(); testblockname.Text = (num + 1) + ". " + title; DrList.Children.Add(testblockname); } }
Thank you in advance!
source share