如何在我的Windows Phone 8应用程序的隔离存储中编写JSON数据对象

时间:2014-09-24 14:18:00

标签: c# xaml windows-phone-8

我有一个问题,我有一个列表类型ObservableCollection<>。我想将此列表保存到隔离存储中的文件JSON数据对象 怎么用?

1 个答案:

答案 0 :(得分:2)

或者您可以保存ObservableCollection<>直接到IsolatedStorage:

        ObservableCollection<Person> obsPerson = new ObservableCollection<Person>();
        //Storage
        IsolatedStorageSettings.ApplicationSettings["obsPerson"] = obsPerson;
        //Retrieval
        if (IsolatedStorageSettings.ApplicationSettings.Contains("obsPerson"))
        {
            ObservableCollection<Person> obsPerson = (ObservableCollection<person>)IsolatedStorageSettings.ApplicationSettings["obsPerson"];
        }