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

Bind Command to the HelpCommand property

The "Help" button of the RadRibbonView is not visible by default. To learn how to show it and change its icon, read the Show Help Button and Change its Image.

Bind Command to the HelpCommand property

The RadRibbonView exposes a property called HelpCommand which can be bound to an object of type ICommand. This command will be executed when the built-in help button is clicked.In this section we will demonstrate how to create a custom command and bind it to the HelpCommand property.

First, let’s define a RadRibbonView in our view and set the HelpButtonVisibility to True.

Example 1: Defining a RadRibbonView

<telerik:RadRibbonView HelpButtonVisibility="Visible" ApplicationButtonImageSource="Backstage_Icon.png"> 
    <telerik:RadRibbonTab Header="Home"> 
            <telerik:RadRibbonButton SmallImage="paste.png" Text="Paste" /> 
            <telerik:RadOrderedWrapPanel VerticalAlignment="Top"> 
            <telerik:RadRibbonButton SmallImage="copy.png" Text="Copy" /> 
            <telerik:RadRibbonButton SmallImage="cut.png" Text="Cut" /> 
    <telerik:RadRibbonTab Header="Insert" /> 
    <telerik:RadRibbonTab Header="References" /> 

Next, we will create a DelegateCommand object.

Example 2: Define a DelegateCommand

public DelegateCommand OpenHelpPageCommand { get; set; } 
public MainWindow() 
    OpenHelpPageCommand = new DelegateCommand(ExecuteCommandHandler, CanExecuteCommandHandler); 
    this.DataContext = OpenHelpPageCommand; 

The HelpCommand property will accept every object that implements the ICommand interface. The DelegateCommand class is one such implementation.

You can implement your logic in the Execute and CanExecute handlers of the DelegateCommand.

Example 3: Implement the Execute and CanExecute methods

private bool CanExecuteCommandHandler(object obj) 
    // Implement logic that checks if the button command can be executed 
    return true; 
private void ExecuteCommandHandler(object obj) 
    // Implement the logic that should be executed when the button is clicked 
    MessageBox.Show("Help Command Executed"); 
Private Function CanExecuteCommandHandler(obj As Object) As Boolean 
    ' Implement logic that checks if the button command can be executed' 
    Return True 
End Function 
Private Sub ExecuteCommandHandler(obj As Object) 
    ' Implement the logic that should be executed when the button is clicked' 
    MessageBox.Show("Help Command Executed") 
End Sub 

Finally, you can bind the command as demonstrated in Example 4.

Example 4: Binding the HelpCommand property to the custom command

<telerik:RadRibbonView HelpButtonVisibility="Visible" HelpCommand="{Binding}" /> 

In addition you can use the HelpCommandParameter and the HelpCommandTarget properties of the RadRibbonView in order to pass additional data to the command.

Find a runnable project of the previous example in the WPF Samples GitHub repository.

See Also

In this article