Skip to main content

Conditional Navigation

The XtraWizard control provides the WizardControl.SelectedPageChanging event, which enables you to implement conditional (not linear) navigation. To do this, you should handle the WizardControl.SelectedPageChanging event, which is raised when a new wizard page is about to be selected.

By default, when an end-user clicks the Next or Back button, the XtraWizard control selects the next or previous page within its WizardControl.Pages collection. This new page is returned by the event parameter’s WizardPageChangingEventArgs.Page property. The previously active page is returned by the WizardPageChangedEventArgs.PrevPage property. To obtain in which direction a user navigates, use the WizardPageChangedEventArgs.Direction property.

If you don’t desire the default behavior and want to select a specific page, all you have to do is to assign this page to the WizardPageChangingEventArgs.Page property.

private void wizardControl1_SelectedPageChanging(object sender,
DevExpress.XtraWizard.WizardPageChangingEventArgs e) {
    // ...

    if(e.PrevPage == wpQuestion && e.Direction == Direction.Forward) 
        if(ceYesAnswer.Checked) e.Page = wpProgress;

    if(e.PrevPage == wpProgress && e.Direction == Direction.Backward)
        e.Page = wpQuestion;

    // ...
}

Note

The full source code can be found in our WizardTourDemo shipped with the XtraWizard Suite.