views:

64

answers:

1

I am using ViewModelLocator pattern. I have the following situation:

Page1<->VM1 => Navigate => Page2<->VM1 => Navigate => Page3<->VM3

                                                => Page 4<->VM4

                                                => Page 5<->VM5

I will show Page2 using VM1 but the controls that will take input will bind to another VM2. This way I can take care of display using content from VM1 and take action for user input using VM2. How can I achieve this in a clean way. Is there a better alternative approach for such scenario?

thanks.

A: 

If you need to bind to 2 different VMs in a single view just bind the second ViewModel to the "root" element of the section you want to bind to that VM. In other words set the datacontext via DataContext="{Binding Source={StaticResource viewModelLocator}, Path=ViewModel}"

Doobi
Thanks for your response.
curiousone