Creating a Universal Windows App and can't found the Settings template in Visual Studio?
This base class helps you to create an observable, strongly typed settings class.
To use it follow the next steps:
- Reference the Common library proyect.
- Create a new class inheriting from ObservableSettings
- Call to the base class constructor indicating if you want to store the settings in LocalSettings or in RoamingSettings.
- Add all your properties calling the base class members Set and Get in the getter and in the setter.
Optionally you can set a default value decorating the property with DefaultSettingValue attribute.
Here an example of use:
namespace Test
{
public class Settings : ObservableSettings
{
private static Settings settings = new Settings();
public static Settings Default
{
get { return settings; }
}
public Settings()
: base(ApplicationData.Current.LocalSettings)
{
}
[DefaultSettingValue(Value = 115200)]
public int Bauds
{
get { return Get<int>(); }
set { Set(value); }
}
}
}
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
No history jet.
Thanks to Tamás Deme (http://stackoverflow.com/users/4788286/tam%c3%a1s-deme) for helping me about reflection in Universal Windows Platform (http://stackoverflow.com/questions/35449747/why-my-uwp-app-cant-call-to-type-getproperties-method/35455271#35455271)
No license. Use it. Modify it. Enjoy it.