This example demonstrates how to use the WizardService and specify the visibility and availability of wizard buttons.
The WizardService generates WizardPages based on the template defined by the PageGeneratorTemplate property. This template allows you to implement navigation between pages at the ViewModel level. In this example, the WizardPage's Allow_ and Show_ properties are bound to the page's ViewModel properties. Use these properties to hide and disable specific navigation buttons.
<dxco:WizardService>
<dxco:WizardService.PageGeneratorTemplate>
<DataTemplate>
<dxco:WizardPage ShowNext="{Binding ShowNext}" ShowBack="{Binding ShowBack}"
ShowCancel="{Binding ShowCancel}" ShowFinish="{Binding ShowFinish}"
AllowNext="{Binding AllowNext}" AllowBack="{Binding AllowBack}"
AllowCancel="{Binding AllowCancel}" AllowFinish="{Binding AllowFinish}" />
</DataTemplate>
</dxco:WizardService.PageGeneratorTemplate>
</dxco:WizardService>
You can specify Show_ and Allow_ properties in both WizardPage and Wizard. The Wizard's properties have a higher priority than corresponding WizardPage's properties.
ViewModels in this project implement ISupportWizard_Command interfaces that expose the Can_ property and the On_ method. Use the Can_ property to enable/disable the corresponding navigation button. When a user clicks the button, the Wizard executes the On_ method, and the WizardService.Navigate method switches the Wizard to the specified page. The ISupportWizard_Command's properties have a higher priority than corresponding WizardPage's properties.
public class WelcomePageViewModel : WizardViewModelBase, ISupportWizardNextCommand {
protected WelcomePageViewModel() {
ShowCancel = true;
ShowNext = true;
}
public static WelcomePageViewModel Create() {
return ViewModelSource.Create(() => new WelcomePageViewModel());
}
public bool CanGoForward {
get { return true; }
}
public void OnGoForward(CancelEventArgs e) {
GoForward();
}
protected void GoForward() {
this.GetRequiredService<IWizardService>().Navigate("PlayTunePage", Model, this);
}
}
The following table lists Wizard buttons and API used to customize their behavior:
Button | WizardPage.Allow_ | WizardPage.Show_ | Interface | Can_ Property | On_ Method |
---|---|---|---|---|---|
Next | AllowNext | ShowNext | ISupportWizardNextCommand | CanGoForward | OnGoForward |
Back | AllowBack | ShowBack | ISupportWizardBackCommand | CanGoBack | OnGoBack |
Cancel | AllowCancel | ShowCancel | ISupportWizardCancelCommand | CanCancel | OnCancel |
Finish | AllowFinish | ShowFinish | ISupportWizardFinishCommand | CanFinish | OnFinish |
This example uses the DevExpress ThemedWindow as a dialog container. In this case, set the ThemedWindowOptions.UseCustomDialogFooter
attached property to true
to remove the duplicated dialog footer:
<dx:DialogService.DialogStyle>
<Style TargetType="dx:ThemedWindow">
<!-- ... -->
<Setter Property="dxi:ThemedWindowOptions.UseCustomDialogFooter" Value="True"/>
</Style>
</dx:DialogService.DialogStyle>
- MainWindow.xaml (VB: MainWindow.xaml)
- WelcomePage.xaml (VB: WelcomePage.xaml)
- PlayTunePage.xaml (VB: PlayTunePage.xaml)
- CongratulationsPage.xaml (VB: CongratulationsPage.xaml)
- MainWindowViewModel.cs (VB: MainWindowViewModel.vb)
- WizardViewModelBase.cs (VB: WizardViewModelBase.vb)
- WelcomePageViewModel.vb (VB: WelcomePageViewModel.vb)
- PlayTunePageViewModel.cs (VB: PlayTunePageViewModel.vb)
- CongratulationsPageViewModel.cs (VB: CongratulationsPageViewModel.vb)
(you will be redirected to DevExpress.com to submit your response)