Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVVM- How would I go about propagating settings between my main view-model (and other view-models) and my settings dialog?

I am building a settings dialog for my application and right now all of the settings correspond with settings on the main view-model, but as I add more view's and view-models some may not.

I need to know what the best practice is for loading the current settings into the settings dialog and then saving the settings to thier corresponding view-models if the user clicks okay.

I will not be using the Properties.Settings.Default system to store settings since I want my application to be as portable as possible and this would store user scoped settings in the directory: C:\Users\ username \Local Settings\Application Data\ ApplicationName Instead of in my application's directory.

In case it makes any difference I am using the MVVM Light Toolkit by Laurent Bugnion.

like image 854
Justin Avatar asked Apr 25 '10 00:04

Justin


1 Answers

How about implementing that with the Messenger of the toolkit?

When changes are made in the Settings ViewModel you just inform anyone interested:

Messenger.Send<Settings>(changedSettings);

And all Viewmodels which need to know if settings have been changed register to that message:

Messenger.Register<Settings>(this, delegate(Settings changedSettings){loadSettings(changedSettings);});

Have a read here: Mvvm light messenger or check this similar post mvvm-light-how-to-access-property-in-other-view-model

like image 94
CodeWeasel Avatar answered Sep 26 '22 00:09

CodeWeasel