I'm building my first WPF and MVVM application. I have 3 views (with 3 corresponding ViewModels)
1) MainWindow (Window)
2) ViewClients (UserControl)
3) ViewModClient (UserControl)
In Clients ViewModel I have a property SelectedClient that keeps track of the selected client on a DataGrid in the view. In this view, I also have a button related with an ICommand defined in MainWindow ViewModel. I resolve it with this binding:
Command="{Binding Path=DataContext.CreateViewsCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" CommandParameter={x:Type local:ViewModClient}
I use CommandParameter to tell the mainWindow ViewModel which kind of view to create and keep the viewmodel isolated from views knowledge. This works great.
Now the problem:
In the ModClient ViewModel I need to load the client's data. So how do i relate this with the SelectedClient from Clients View while keeping the MVVM pattern? (I can only use one CommandParameter and it's already used)