Note that there are some explanatory texts on larger screens.

plurals
  1. POTombstoning a List on Windows Phone 8
    primarykey
    data
    text
    <p>I am trying to save the state of a listbox on wp. I used this this method to tombstone the content of a textbox and it worked perfectly but I am having problems for a list of strings :</p> <p>Basically I have a list of strings called beta and I have to click on a button to generate the list. So I would like that if I close or deactivate my application and then relaunch it, the list shows up without pressing the button </p> <pre><code> List&lt;string&gt; beta; private void b_Click_1(object sender, RoutedEventArgs e) { List&lt;string&gt; beta = new List&lt;string&gt;{ "string","string","string", "string","string","string", "string", }; list.ItemsSource = beta; phoneAppService.State["_List"] = beta; } private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e) { object myValue; if(phoneAppService.State.TryGetValue("_List", out List&lt;myValue)&gt; ){ list.ItemsSource = myValue; } } </code></pre> <p>but a problem occurs at : </p> <pre><code>phoneAppService.State.TryGetValue("MyValue", out List&lt;myValue)&gt; </code></pre> <p>Although this method works with one string it does not with a list.</p> <p>Which method should I use for a list of strings?</p> <p>EDIT :</p> <p>Here are my methods in my app.xaml.cs class that I call when the app is closed, deactivated, launched or opened :</p> <pre><code> private void SaveState() { PhoneApplicationService phoneAppService = PhoneApplicationService.Current; IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings; settings["MyValue"] = phoneAppService.State["MyValue"]; if(settings.Contains("_List")){ settings["_List"] = phoneAppService.State["_List"]; } } private void LoadState() { PhoneApplicationService phoneAppService = PhoneApplicationService.Current; IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings; string myValue = ""; if(settings.TryGetValue&lt;string&gt;("MyValue", out myValue )){ phoneAppService.State["MyValue"] = myValue; } List&lt;string&gt; myValues; if (settings.TryGetValue&lt;List&lt;string&gt;&gt;("_List", out myValues)) { phoneAppService.State["_List"] = myValues as List&lt;string&gt;; } } </code></pre> <p>As I said earlier this method works for a string which is properly restored in a textbox but not for a list of string</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload