0

I have this settings class

class AppSettings : ApplicationSettingsBase
{
    [UserScopedSettingAttribute()]        
    public ObservableCollection<TrackViewModel> TracksViewModel
    {
        get { return (ObservableCollection<TrackViewModel>)(this["TracksViewModel"]); }
        set { this["TracksViewModel"] = value; }
    }

...

TracksViewModel has a property Track (my Model), which is a class. Also this class has a empty constructor, so I guess this make no problem.

Anyway, when I save Settings, all the Properties are saved but Track object. In output debug I got no errors.

Any suggestion ?

user1649247
  • 47
  • 2
  • 7

1 Answers1

0

How does the appsettings know they type of the ViewModel? You may want to check the serialization of that object.

Or, you many want to not use appsettings for this and roll your own xml file for persisting that stuff.

Here are several links:

http://www.codeproject.com/Articles/6730/Custom-Objects-From-the-App-Config-file

How to store class object in app config file

Can I save an object to the app.config file?

How to Read Custom XML from the app.config?

How to serialize collections in .net

Community
  • 1
  • 1
Josh C.
  • 4,303
  • 5
  • 30
  • 51
  • I wish to prefer to continue using ApplicationSettingsBase Sorry, how could I solve this ? I tried to put [Serializable()] up to Track object, but nothing happens – user1649247 Oct 08 '12 at 22:08
  • Now that you have marked your class as serializable, have you implemented the process of serialization? – Josh C. Oct 08 '12 at 22:19
  • Do you mean implementing ISerializable? No I didn't... Honestly I don't know much about the process. I'm trying to read something about this. Do you know some useful sources ? Thank you very much (Sorry but I've no enough reputation to mark your answer useful) – user1649247 Oct 08 '12 at 22:29
  • @user1649247 I've added some links in my answer. – Josh C. Oct 09 '12 at 13:22