Skip to content

DevExpress-Examples/how-to-use-the-wpf-wizardservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to Use the WPF WizardService

This example demonstrates how to use the WizardService and specify the visibility and availability of wizard buttons.

image

Implementation Details

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>

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

This example demonstrates how to use the WPF WizardService.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 8