MVVM Binding to Properties.Settings
In a MVVM app开发者_C百科roach how would I go about binding to Properties.Settings? Is there a way to bind a property in C# code(in the ViewModel) to another property(Properties.Settings.Default) or should i just bind to standard properties and on save make sure each property gets propogated manually to the Properties.Settings?
Something like the latter: expose settings in Properties.Settings.Default via properties on the ViewModel as appropriate for the view.
public class SomeViewModel
{
public int SomeProperty
{
get
{
return Properties.Settings.Default.SomeProperty;
}
set
{
Properties.Settings.Default.SomeProperty = value;
}
}
}
...or code to that effect.
The settings implement INPC, so you could simply bind directly to the settings from your view. Remember that you manually have to call Save() on the settings to actually save them into isolate storage.
精彩评论