multi screen same viewmodel back and forward navigation

Topics: Prism v4 - Silverlight 4
Nov 16, 2010 at 5:27 PM

We have a scenario where we are looking to intake about 40 data items from a user. These items could be split up as 8 views with 5 items each. Basically the scenario is flexible data input.

There are multiple domain models in play e.g. the first 2 views may only be concerned with personal contact details the next 2 views with current product preferences the next with financial history, a view could contain data from more than one domain e.g. a mix of questions display on the same view.

It should be possible to go backwards and forwards between the views but not exit the process (ignore the possibility of the browser being killed) until all questions have been satisfied.

What would you recommend as an approach for this scenario using Prism?

Nov 16, 2010 at 6:26 PM


Based on my understanding, your scenario requires to create an only one instance of a ViewModel and it will be assigned to many Views. First of all, there is not guidance on this topic in Prism out-of-the-box.

That said, in general the context of views is assigned with its own ViewModel(s) after creating the those views. But it is not something impossible to achieve, since you could use the ViewModel-First pattern (this is mentioned as a possible approach here). In this separated presentation patterns the ViewModel will be responsible for creating the view/views and binding itself to the view/views. For more information on this topic, you could take a look at Rob Eisenberg's presentation at MIX: Build your own MVVM Framework.

Regarding to back and forward navigation, it is something supported by Prism Navigation using the Journal. For more information on this topic, you could take a look at the following documentation section on MSDN: Chapter 8: Navigation, see the Using the Navigation Journal section.

If you need more guidance on this topic, you could check the View-Switching Navigation QuickStart.

Hope this helps.

Fernando Antivero