I am working on my first WPF/MVVM application, and I have come across a limitation in my knowledge of commands!
Here is my scenario.
I have a window – Customer.xaml.
It houses 2 usercontrols
- viewCustomerSearch.xaml
- viewCustomerDetails.xaml
Each of THOSE has it’s own view model.
So, the hierarchy looks like this:
… Customer.xaml
… … viewCustomerSearch.xaml
… … … viewmodelCustomerSearch.xaml
… … viewCustomerDetails.xaml
… … … viewmodelCustomerDetails.xaml
I understand this to be a ‘not uncommon’ scenario.
For what it is worth, the user selects a customer by double clicking on a listview line in the viewCustomerSearch.xaml control.
The problem is: I now need to tell the viewmodelCustomerDetails.xaml class which customer the user has just selected. I cannot work this out at all.
Does anyone have any help on where I declare the command I need, how it gets hooked up, where the implementation code fires, etc?
Any help gratefully appreciated,
DS
Typically, to do inter-viewmodel communication, you can either:
Frameworks such as Caliburn.Micro and Prism provide an implementation of the event aggregator pattern.