I am currently creating a usercontrol in wpf which consists of several 'screens' that the user will click through.
I am trying to do this in a relatively nice MVVM way but am having a bit of trouble passing properties to each view.
For each 'screen' I have created a view with it's own viewmodel (e.g. View1.xaml, View2.xaml). The main usercontrol can then access these views:
<UserControl.Resources>
<local:ModuleBaseViewModel x:Key="ViewModelDataSource" />
</UserControl.Resources>
<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource ViewModelDataSource}}">
<Grid Background="#FF054549">
<local:View1 Visibility="Visible"/>
<local:View2 Visibility="Hidden"/>
</Grid>
</Grid>
Now, I have some properties that I would like to share between each view (for example background color). If I put this property in the main usercontrol viewmodel then it gets ignored because each view has it's DataContext set to it's own viewmodel.
Is there a way of passing down the property to each of the viewmodels without having to duplicate it? Or am I doing it completely wrong?
Thanks!