views:

823

answers:

4

All in WPF:

Developing a wizard application, user has to answer a number of simple questions before brought to the main app. The main app is then prefilled with the information obtained from the wizard.

I started with a Window which I then planned to add usercontrols to. The main window would have the user control in the first row, then Next and Previous buttons to control moving between the controls in the second row. This way I could easily control the logic to switch between screens like:

WizardControl1.IsVisible = false;
WizardControl2.IsVisible = true;

But for some reason, user controls do not have setter for IsVisible. Hurray.

So then I thought I would just use seperate windows for each section of the wizard. The problem with this approach is that now when stepping between, the window opens in random positions, and by steppign through the wizard with next, the next window pops up randomly which is really distracting and frustrating.

So how can I develop a wizard properly? I don't get why this is so hard...not exactly rocket science... replacing text and controls and storing input after pressing next/previous!

Thanks

+1  A: 

I'd probably aproach this using data binding and template selectors. Have the wizard form bind to a "WizardData" class, which exposes a list of "WizardPage" base classes.

The WizardData class can expose properties defining the correct info on the forms, and display a control for the main page that uses a template selector to determine the proper control to display based on the actual type of the particular wizard page.

It sounds like more work than it is, really. It also gives you the benefit of good separation between code and UI (all "work" is done by the WizardData and WizardPage classes), and the ability to test logic independent of the UI.

It's also a very WPF/MVVM way of approaching the problem.

kyoryu
do you know where any examples are which could help get me started? I'm not sure how to do what you say "Have the wizard form bind to a "WizardData" class, which exposes a list of "WizardPage" base classes"
baron
I'll see if I can throw a quick example together.
kyoryu
A: 

I recognize this does not directly address your question, but I thought I'd mention it as a possible alternative. I've used Actipro's Wizard control with pretty good results, and when I have needed support, they have been very responsive. I am not affiliated with them in any way; I just like not having to write the plumbing to manage a wizard.

David Veeneman
A: 
  1. The property is called "Visibility".
  2. I find that I do better when I dynamically add and removing controls rather than hide them.
Jonathan Allen
+1  A: 

Check this link: http://www.codeproject.com/KB/WPF/InternationalizedWizard.aspx This is the article about building wizard in WPF by Josh Smith, it's seems to be nice pattern. I found it's helpful for me, hope you'll too.

klement