I have two view models ViewModelA and ViewModelB they both use a common DataServiceA to retrieve a User Setting called Theme. ViewModelB can change that setting and save it to the database. When this occurs the ViewModelA does not update that theme value.
I have been trying to figure out the proper course of action to allow it to update it as well and have come up with a few options:
- Make the DataService raise a property notification when a value is saved (I don’t like this)
- Use MessengerService to keep them in sync. (I am having issues running into a messaging loop)
- Pass one ViewModel to the other
Any ideas?
If both of them use the same instance of
DataServiceA, I don’t think it’s such a bad idea thatDataServiceAwill also implement INotifyPropertyChanged and raise an event when theThemeproperty changes.But if you don’t like that idea, another option is to use the EventAggregator and publish the event. I personally think the first option is quite sufficient but it’s your call…