I have some global options that should appear from the ViewModel and should be available for all DataTemplates in all UserControls. It includes things like GlobalButtonMargin, GlobalStrokeWidth or GlobalWorkspaceBackgroundColor. These things are in the viewmodel because the user can edit these settings at runtime.
How are you going to implement this in a good MVVM style?
I was thinking about having a Singleton GlobalSettingsViewModel. Is this the preferred approach? If so, how can I use a singleton instance from XAML?
Another way would be to pass GlobalSettings to all the ViewModel instances that exist in my application, so I can access from the models for which I create DataTemplates. But it is unclean.
The third approach is to rotate the ViewModel alltogether approach to determine what is the XAML resource and dynamically set the resources at runtime using FindResource.
Could you sketch, how would you develop an application to support this scenario?
source
share