New to Telerik UI for WPF? Download free 30-day trial


RadWizard provides a set of built-in commands that enables you to easily handle the User Interface actions, but still make your logic independent of the UI layout.

All supported commands are defined in the RadWizardCommands class and are listed below:

  • Cancel
  • Finish
  • Help
  • MoveCurrentToPrevious
  • MoveCurrentToNext

Using The RadWizardCommands

In order to utilize the built-in RadWizard commands, you can set them directly to the Command property of a button. Thus, once you click the button, the predefined command will be executed.

There are two major scenarios to define a RadButton – inside and outside RadWizard. The wizard namespace definition is as follows:

Definition of the namespace needed to use the built-in commands of RadWizard

Example 1 illustrates how to add a RadButton within the FooterTemplate of RadWizard.

Example 1: Demonstrates how you can use the built-in commands inside RadWizard

            <telerik:RadButton Content="Back"  
                               Width="70" Height="25" 
Once the source object is defined up in the tree as a DataContext, you can set the source for the CommandParameter property's binding to be the entire object.

The other approach is to define the RadButton beyond the boundaries of RadWizard.

Example 2: Demonstrates how you can use the built-in commands outside RadWizard

<telerik:RadButton Content="Back"  
                   CommandTarget="{Binding ElementName=myWizard}" /> 
In this case the target object needs to be explicitly set in the definition of the CommandTarget property, specifying the RadWizard towards which the command has to be executed. This specific command will be automatically disabled until a change in any of the items in the RadWizard is made.

Execute RadWizardCommands Programmatically

All RadWizardCommands are of type RoutedUICommand. So, for example, you may easily handle the Click event of a button, and execute your command. However, when invoking the command in such a manner a second parameter should be added, pointing out the target UI Element as shown in Exapmle 3.

Example 3: Executing wizard command from code behind

private void RadButton_Click(object sender, RoutedEventArgs e) 
    var moveCurrentToNextCommand = RadWizardCommands.MoveCurrentToNext as RoutedUICommand;  
    moveCurrentToNextCommand.Execute(null, this.wizard);  

Custom CommandProvider

RadWizard also exposes a CommandProvider property, which allows you to customize the behavior of the commands in an MVVM-friendly way. Each of the commands listed in the beginning of the article can be customized by overriding its corresponding Execute/CanExecute method. Examples 3 and 4 demonstrate a custom CommandProvider implementation.

Example 4: Creating a custom WizardCommandProvider

public class CustomCommandProvider : WizardCommandProvider 
    public CustomCommandProvider() : base(null) 
    public CustomCommandProvider(RadWizard wizard) : base(wizard) 
    protected override void Finish() 
        if (MessageBox.Show("Are you sure?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) 
            // prevent finish 
Public Class CustomCommandProvider 
    Inherits WizardCommandProvider 
        Public Sub New() 
        End Sub 
        Public Sub New(ByVal wizard As RadWizard) 
        End Sub 
        Protected Overrides Sub Finish() 
            If MessageBox.Show("Are you sure?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) = MessageBoxResult.No Then 
                ' prevent finish 
            End If 
        End Sub 
End Class 

Example 5: RadWizard with custom CommandProvider implementation

        <local:CustomCommandProvider x:Key="CommandProvider"/> 
    <telerik:RadWizard CommandProvider="{StaticResource CommandProvider}"> 
            <telerik:WizardPage ButtonsVisibilityMode="All" NextButtonContent="Continue" CancelButtonContent="Stop"> 
                <TextBox Text="Wizard Page 1" /> 
            <telerik:WizardPage ButtonsVisibilityMode="Cancel,Finish" NextButtonContent="Finish" CancelButtonContent="Stop"> 
                <TextBlock Text="Wizard Page 2" /> 

See also

In this article