I have a MainWindow
and 7 UserControls with their own VM's.
My MainWindow
has two Strings (email and language) which I need in all 7 UserControls. I found a solution (simple Dependency Properties
for each UserControl
) but I don't want to do that 7 times for each UserControl
because that doesn't seem right for me. Is there a better way of doing this?
If you're using a ViewModelBase class with the INotifyPropertyChanged interface (usually standard in an MVVM app) then simply add you're two strings here. All of you're subsequent ViewModels will inherit these properties, eliminating the need to implement the two properties in each of your ViewModels.
If you mark the class and the properties as abstract, this would force derived classes to override the two properties.