Wizard
A Wizard shows one WizardStep at a time, with a step list at the top, the step title and description, and Cancel, Back, Skip and Next (Finish on the last step) buttons.
Video tutorial: Wizard. All videos: Video tutorials.
<UIToolbox.Wizard name="setup" allow-step-clicking="true" finish-text="Complete Setup">
<UIToolbox.WizardStep name="welcome" title="Welcome" description="This wizard sets up a user account." />
<UIToolbox.WizardStep name="user" title="User">
<ui:TextField name="username" label="User name" />
</UIToolbox.WizardStep>
<UIToolbox.WizardStep name="advanced" title="Advanced" can-skip="true" />
<UIToolbox.WizardStep name="summary" title="Summary" can-go-back="false" />
</UIToolbox.Wizard>
wizard.GetStep("user").Validator = step =>
{
if (step.Q<TextField>("username").value.Length > 0) return true;
wizard.ShowValidationError("Enter a user name.", step.Q<TextField>("username"));
return false;
};
wizard.GetStep("advanced").VisibilityCondition = () => expert.value;
expert.RegisterValueChangedCallback(_ => wizard.Refresh());
| Member | Description |
|---|---|
WizardStep Title, Description (title, description) |
The page heading and the text under it. An empty title shows the step name. |
WizardStep.CanSkip (can-skip) |
Shows the Skip button on the step. |
WizardStep.CanGoBack (can-go-back) |
False turns off Back and the step-list clicks to earlier steps on this step. The default is true. |
WizardStep.Validator |
Returns false to stop Next, Finish and a forward step-list click. Call ShowValidationError in it to tell the user why. Give it the field with the error to put that field in the error state. |
WizardStep.VisibilityCondition |
Returns false to leave the step out (a branch). Call Refresh when the condition changes. |
WizardStep.IsCompleted |
True after Next, Skip or Finish leave the step. |
ShowProgress, ShowStepNumbers, AllowStepClicking (show-progress, show-step-numbers, allow-step-clicking) |
The step list, the numbers in it (a check mark on a completed step), and clicks on it. |
CancelText, BackText, SkipText, NextText, FinishText |
The button texts (cancel-text and so on). |
Next(), Back(), Skip(), Finish() |
The button actions. Each returns false when the move is not allowed. Back does not validate. |
CancelAsync(), CancelConfirmation |
The Cancel button. CancelAsync awaits CancelConfirmation, then sends Cancelled; it returns false when the confirmation says no. Null cancels at once. While a confirmation is open, another cancel does nothing. |
GoToStep(name), Reset(), InsertStep(index, step), GetStep(name) |
Moves without a check; clears the completed marks and shows the first step; adds a step; finds a step. |
Steps, VisibleSteps, CurrentStep, IsLastStep, ValidationError |
The state. |
SaveState(), RestoreState(json) |
The current step and the completed steps as JSON. The fields in the steps are not saved. |
StepChanged(from, to), StepCompleted(step), Completed(steps), Cancelled |
The events. Completed gets the visible steps. |
StepValidating(args) |
Comes before each move by Next, Back, Skip, Finish or a step-list click. args has Step, Target (null for Finish), Direction (Forward, Backward or Skip) and IsFinish. Set Cancel to stop the move. |
- The steps are the wizard's content:
Addputs a step in the content area. CallRefreshafter anAddwhile the wizard shows. - A step-list click goes back when the current step can go back. It goes forward when all the steps between are completed; it validates the current step first.
- Skip marks the step completed, so a step-list click can go past it.
Cancelleddoes not reset or close anything. The owner closes the window. To ask first, setCancelConfirmation:
wizard.CancelConfirmation = async () =>
await MessageBox.ShowAsync(this, "Discard the setup?", "Cancel", MessageBoxButtons.YesNo) == MessageBoxResult.Yes;
- The buttons stay at the bottom of the wizard when the wizard has a height from its parent: the content area takes the free space. A window puts its content in a
ScrollViewby default, and there the wizard is only as tall as the current step, so the buttons move from step to step. Setenable-scrolling="false"on the window to keep the buttons at the bottom of the window:
<tb:Window id="setup" title="Setup" width="520" height="400" enable-scrolling="false">
<UIToolbox.Wizard style="flex-grow: 1;"> ... </UIToolbox.Wizard>
</tb:Window>
- A step that can be taller than the wizard needs its own
ScrollView: the content area clips. - The buttons reuse the
MessageBoxbutton style. - A move to another step slides the new step in, from the right after a forward move and from the left after a backward move, and fades it in. The old step hides at once. A new move stops the last transition. There is no transition when the workspace has
AnimationsEnabledoff, or forResetandRestoreState. - The content area clips, so the slide does not change the size of a parent
ScrollView. It also clips a child that reaches past the content, such as a focus ring on the edge. StepValidatingcomes after theValidatorof the step on a forward move. It clears the old validation error first, so callShowValidationErrorin the handler to tell the user why the move stopped:
wizard.StepValidating += e =>
{
if (e.Direction != WizardDirection.Backward || !unsavedChanges) return;
e.Cancel = true;
wizard.ShowValidationError("Save the changes first.");
};
GoToStep,ResetandRestoreStatedo not sendStepValidating.
Styling
| Class | Element |
|---|---|
tb-wizard |
The wizard. It grows to fill its parent. |
tb-wizard__steps |
The step list (a row with a bottom border). |
tb-wizard__step |
An item in the step list (faded). |
tb-wizard__step--current |
The item of the current step (not faded, accent number, bold title). |
tb-wizard__step--completed |
The item of a completed step (not faded, accent check mark). |
tb-wizard__step--clickable |
An item that a click can go to (accent title on hover). |
tb-wizard__step-number |
The number or check mark circle (20 px). |
tb-wizard__step-title |
The title in an item. |
tb-wizard__title |
The page heading (15 px, bold). |
tb-wizard__description |
The text under the heading (muted). |
tb-wizard__content |
The area that holds the steps (grows, clips). |
tb-wizard-step--enter-next, tb-wizard-step--enter-back |
The start of the step transition: 24 px to the right or the left, opacity 0. The wizard removes the class to play the transition. |
tb-wizard-step--anim |
The transition on a step while it comes in: translate and opacity, --tb-animation-duration-fast, entrance easing. |
tb-wizard__error |
The validation error (danger color). |
tb-wizard__buttons |
The button row. |
tb-wizard__button, tb-wizard__button--default |
The buttons and the Next/Finish button. The MessageBox button rules style them. |