A static class as Phil mentions is a fine idea, but I would suggest looking into using dependency injection. You may not need a full IoC container, but that would probably help for your scenario. Caliburn.Micro makes it very easy to integrate such a container.
Create a Settings
class. (I would also create an ISettings
interface so that you could pass stub settings into your view models for testing, but that's an extra bonus.) Then make all of your ViewModels require an instance of ISettings
in their constructors.
When your app starts, you create one instance of Settings
that reads from IsolatedStorage or wherever else you have settings, then pass that instance into any ViewModel that gets created.
That Settings
class can be responsible for saving settings back to IsolatedStorage whenever it needs to.
An example of this scenario:
In AppBootstrapper
class:
PhoneContainer container;
ISettings settings;
protected override void Configure()
{
// Your usual stuff go here
settings = new Settings();
settings.LoadSettings();
container.Instance(settings);
}
In your ViewModel class:
ISettings settings;
public MainPageViewModel(ISettings settings)
{
this.settings = settings;
}
At this point you will have all your settings available for your ViewModel.