user65168
user65168

Reputation:

How to store a collection of Custom type objects in the Settings file in WPF?

I would like to serialise a collection of Custom objects in the Settings file of WPF application. I am able to serialise a single Custom object by deriving from ApplicationSettingsBase, however I am unable to serialise a collection of these objects. Could you please help?

Thanks in advance!

public class TestSetting: ApplicationSettingsBase
{
    [UserScopedSetting]
    public string Name
    {
        get { return (string) this["name"]; }
        set { this["name"] = value; } 
    }
}

Upvotes: 2

Views: 570

Answers (1)

Jobi Joy
Jobi Joy

Reputation: 50038

You can create a class derived from ApplicationSettingsBase, in which you can put your collection as a property and each and every Class inside the collection can be just [Serializable()].

Upvotes: 2

Related Questions