views:

126

answers:

3
+6  Q: 

MVVM like wizard

Hi,

I am currently building an MVVM based application. The application should also have a wizard in MVVM style. The wizard is not a normal wizard, its a particular kind of a wizard. My goal is to implement a wizard with

1.) has also multiple branches. The wizard can guide you in other direction. So the wizard must not be straightforward.

2.) can also have short cuts. You can skip some pages where default values are setted.

3.) is also normal - straightforward.

Note, some information in the wizrad pages are on-the-fly. That means, that the information can be passed between each step and processed.

Are there any approaches like patterns to solve my problem? How do I implement it the best way?

+1  A: 

If your wizard has a single VM that stores the state/results of each step and sits behind a view that is a user control...

You could have a Frame on the wizard view that requires 2 events in the code behind (This obviously depends on if your MVVM architecture can live with this?).

Event 1) When the binding of your wizards step raises its NotifyPropertyChanged: tell your frame to "Navigate" to the appropriate page (as described in a property in your wizard VM).

Event 2) On the frames "Navigated" event so that you can point the current pages data-context at your VM.

This way the wizard viewmodel controls the state of the wizard from start to finish and it also can describe the steps, which can easily be added to, edited, etc.

Obviously this may not sit well with everyone's view of MVVM.

jdoig
+2  A: 

Did you read this good article in Code Project about Wizard in MVVM and written by two MVVM guru: http://www.codeproject.com/KB/WPF/InternationalizedWizard.aspx?display=Print

Florian
+1  A: 

You might have a look at the ViewModel sample application of the WPF Application Framework (WAF). It shows how to implement a Wizard in a MVVM way.

jbe