Edit this page

RadialMenuItem Commands

RadRadialMenuItem provides a Command property that can be bound to an ICommand implementation. The execution of the command is triggered by click/tap event. The parameter passed to the command is set through the CommandParameter property of the RadialMenuItem.

Create a Command

Here is an example demonstrating how to add a command to a RadialMenuItem.

  1. First, create a class that implements the ICommand interface. Example 1 shows a sample implementation.

    [C#] Example 1: Creating a command

    public class CustomItemCommand : ICommand
    {
        public bool CanExecute(object parameter)
        {
            var radialMenuItem = parameter as RadRadialMenuItem;
            if (radialMenuItem != null)
            {
                // perform custom logic here
            }
            return true;
        }
    
        public void Execute(object parameter)
        {
            var radialMenuItem = parameter as RadRadialMenuItem;
            if (radialMenuItem != null)
            {
                // perform custom logic here                
            }
        }
    
        public event EventHandler CanExecuteChanged;
    }
    
  2. Add an instance of the custom command class to the Resources of the UserControl.

    [XAML] Example 2: Adding the command to the Resources

    <UserControl.Resources>
        <local:CustomItemCommand x:Key="CustomItemCommand"/>
    </UserControl.Resources>
    
  3. Bind the Command property of the RadialMenuItem to the instance of the custom command as shown in Example 3.

    [XAML] Example 3: Bind the command

    <telerik:RadRadialMenu>
        <telerik:RadRadialMenuItem Header="Item 1" Command="{StaticResource CustomItemCommand}" 
        CommandParameter="{Binding RelativeSource={RelativeSource Self}}" />
        <telerik:RadRadialMenuItem Header="Item 2" Command="{StaticResource CustomItemCommand}" 
        CommandParameter="{Binding RelativeSource={RelativeSource Self}}" />
        <telerik:RadRadialMenuItem Header="Item 3" Command="{StaticResource CustomItemCommand}" 
        CommandParameter="{Binding RelativeSource={RelativeSource Self}}" />
    </telerik:RadRadialMenu>
    

See Also