views:

37

answers:

1

Hello everyone,

I am building my own implementation of a wizard style interface and struggling to get it working correctly, along with every other style of wizard interface I expect to encounter the same problem. See image:

http://img208.imageshack.us/img208/3857/wizardinwindow.jpg

http://yfrog.com/5swizardinwindowj

Basically I am using a grid and have my navigation elements below that. The grid will switch the screens, like so:

private void btnNext_Click(object sender, RoutedEventArgs e)
{
    Wizard.Progress++;
    SwitchUserControl();
}

private void SwitchUserControl()
{
    switch (Wizard.Progress)
    {
        case 0:
            contentGrid.Children.RemoveRange(0, contentGrid.Children.Count);
            contentGrid.Children.Add(screen0);
            break;
        case 1:
            contentGrid.Children.RemoveRange(0, contentGrid.Children.Count);
            contentGrid.Children.Add(screen1);
            break;
        case 2:
            contentGrid.Children.RemoveRange(0, contentGrid.Children.Count);
            contentGrid.Children.Add(screen2);
            break;
        case 3:
            contentGrid.Children.RemoveRange(0, contentGrid.Children.Count);
            contentGrid.Children.Add(screen3);
            break;
    }
}

This is where I get to the problem:

That works fine to switch among the controls. The problem is, say for example on of the screens says enter a date. And I have some data validation code to run on that text field. If validation fails the textbox border goes red and a message appears. But now I don't know where this code can go. I used to have it on the button on the usercontrol screenX, but now my navigation buttons are below, and then if I want to put it on the code under those nav buttons, I can't access the textfield!

I also see this problem occuring in most implementations of wizard style interface. Most examples I see use check boxes or radio buttons so there is no error in data input. But that is not very helpful to this example.

So what are my options to achieve what I want here???

Thanks for vieiwing.

A: 

The answer to your question might be to start over with a more canonical approach. WPF supports a nice Navigation API that you can use for building wizards. Here is a sample of it at work.

With respect to validation, in the Navigation API you can use a Page class in the stead of your controls (from your example). Your Page class can have a property indicating whether it is valid or invalid and you can keep the logic of field by field input validation specific to the page.

David in Dakota
I don't seem to have any NavigationWindow that I can add to the solution. I have the Page Function (WPF) but can't find Navigation window???
baron