Wizard Framework for WPF User Guide

Further Integration

Back to Table of Contents

Decision-Based Navigation

A great deal of wizards can be configured using the properties already described: relying on the default page order and customizing where necessary by explicitly setting the PreviousPage and NextPage properties. Sometimes, however, the user's route through the wizard can only be set at runtime once certain variables are known about. The key to controlling this is, again, setting the PreviousPage and NextPage properties. However we provide some extra methods to help make this easier and more maintainable.

Let us take the scenario where on the first page, the user chooses between two options that lead to different paths through the next few pages. There are six pages in total, and of the four middle pages, the first two are to be associated with the first choice and the second two are to be associated with the second choice. The last page always appears. Remember that when activating such a route, the NextPage property of the decision page has to be set, the PreviousPage of the finish page also has to be set, along with the NextPage property of the last page in the "middle pages". Some code and a diagram will help illustrate this.

<wz:Wizard>
	<wz:WizardPage Name="decisionPage" Title="Decision Page" Description="Choose your route through the wizard."
		BeforeMoveNext="ApplyDecision" />
	<wz:WizardPage Name="d1p1" Title="Decision One Page One" />
	<wz:WizardPage Name="d1p2" Title="Decision One Page Two" />
	<wz:WizardPage Name="d2p1" Title="Decision Two Page One" />
	<wz:WizardPage Name="d2p2" Title="Decision Two Page Two" />
	<wz:WizardPage Name="finishPage" Title="Finish Page" Description="You finished the wizard!" />
</wz:Wizard>

The key to establishing the route at runtime is to handle the BeforeMoveNext event of the decisionPage object, and in its code, use the static Wizard.LinkPages method to link all the relevant pages together. This method takes four parameters: decisionPage, the page on which the decision has been made; firstBodyPage, the first page of the series of pages chosen by the decision; lastBodyPage, the last page of the series of pages chosen by the desicion; and afterPage, the page that follows regardless of which decision is made. Note that the if the "series of pages" chosen by the decision is only one page, the middle two parameters can be the same page. Here's the code for the scenario being discussed in this section. It assumes there is a radio button on the decision page called radioDecisionOne.

private void ApplyDecision(object sender, System.ComponentModel.CancelEventArgs e)
{
	if (radioDecisionOne.IsChecked == true)
		Wizard.LinkPages(decisionPage, d1p1, d1p2, finishPage);
	else
		Wizard.LinkPages(decisionPage, d2p1, d2p2, finishPage);
}

Wizard 97 and Aero Wizard

Wizard Framework has the ability to adhere to two specifications: Wizard 97, and Aero Wizard. The Wizard 97 look and feel was used in versions of 32bit Windows released before Windows Vista and the Aero Wizard look is only present in Windows Vista and upwards. However, both specifications can be used on any version of windows. The key to controlling how your wizard looks is the Appearance property of the WizardWindow class. Note that this property is on WizardWindow rather than Wizard because it is necessary for the window itself to update its appearance when the Aero Wizard look and feel has been specified.

The default value of the Appearance property is Automatic. This will cause Wizard Framework to use the Aero Wizard look and feel when your application is running on Windows Vista and upwards, and Wizard 97 otherwise. It is important to remember that because the metrics of Windows elements can change on the fly, and especially when automatic appearance selection is enabled, your pages must have their contents defined in a way such that they support resizing intelligently.

Certain wizard elements are only supported with the Wizard 97 appearance. The concept of a separately-themed start and finish page, and a description for each page, only exists in the Wizard 97 specification. When run with the Aero Wizard look and feel, your start and finish pages will look just like regular pages and any page descriptions simply will not be seen.

Localization

All text shown by the wizard can be fully localized. The key to doing this is the WizardLanguageStrings class. This class has a number of string properties corresponding to every textual resource that can be displayed by the wizard. The wizard itself exposes a default instance of this class with English strings, but one can be assigned to the wizard in XAML or through code to use different strings:

<wz:Wizard>
	<wz:Wizard.LanguageStrings>
		<wz:WizardLanguageStrings Next="Onward!" />
	</wz:Wizard.LanguageStrings>
	...
</wz:Wizard>

Note that any strings not explicitly specified will just revert to the English setting. Refer to the class library documentation or intellisense for a list of all strings that can be set.

Next: Using the Designer