Note that there are some explanatory texts on larger screens.

plurals
  1. POIsolatedStorageSettings.ApplicationSettings not persisting all properties
    primarykey
    data
    text
    <p>I'm trying to serialize and deserialize this class to Windows Phone ApplicationSettings, but for some reason, only the <code>Items</code> are persisted and not the <code>Title</code> or <code>LastChanged</code> properties. Any ideas as to why are appreciated!</p> <p>Class:</p> <pre><code>public class VehicleCollection : ObservableCollection&lt;Vehicle&gt; { public string Title { get; set; } public DateTime LastChanged { get; set; } public bool HasNoItems { get { return Items.Count == 0; } } public VehicleCollection() { } public VehicleCollection(string title, DateTime lastChanged) { Title = title; LastChanged = lastChanged; } protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) { base.OnCollectionChanged(e); OnPropertyChanged(new PropertyChangedEventArgs("HasNoItems")); } } </code></pre> <p>Persist logic:</p> <pre><code> public static bool SavePersistent(string key, object value) { if (null == value) return false; var store = IsolatedStorageSettings.ApplicationSettings; if (store.Contains(key)) store[key] = value; else store.Add(key, value); store.Save(); return true; } public static T LoadPersistent&lt;T&gt;(string key) { var store = IsolatedStorageSettings.ApplicationSettings; if (!store.Contains(key)) return default(T); return (T)store[key]; } </code></pre> <p><hr /> Edit: I've created a sample project where the behavior is evident. <a href="http://www.fileswap.com/dl/2ar0ygF8w7/" rel="nofollow">http://www.fileswap.com/dl/2ar0ygF8w7/</a></p> <ol> <li>Run the app and watch the static data being created</li> <li>Press "save data" to save to IsolatedStorage</li> <li>Close and re-run the app</li> <li>Watch the title for both collections disappear, as they were not persisted</li> </ol>
    singulars
    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.
 

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