小编RJD*_*ubz的帖子

问题在隔离存储中存储对象列表

我试图存储我在隔离存储中创建的对象列表,并能够通过自动为它们生成标题在列表中显示它们.到目前为止,代码仍然有效,但是一旦我对应用程序进行了逻辑删除并启动它,除了对象列表之外,我的所有数据都会被保存.我认为我的问题可能在于我首先如何初始化列表,或者可能是我如何显示名称.任何帮助表示赞赏.

这段代码在我的App.xaml.cs中:

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();
        }
     }
Run Code Online (Sandbox Code Playgroud)

此代码在我的mainPage上将项添加到列表中:

(Application.Current as App).testList.Add(new my_type());
Run Code Online (Sandbox Code Playgroud)

这段代码是在不同的页面上将标题实现到屏幕上:

 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) …
Run Code Online (Sandbox Code Playgroud)

c# windows list stackpanel windows-phone-7

4
推荐指数
1
解决办法
5681
查看次数

标签 统计

c# ×1

list ×1

stackpanel ×1

windows ×1

windows-phone-7 ×1