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

RadialMenuItem Command

The RadialMenuItem has 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 of RadialMenuItemContext type and exposes the following properties:

  • TargetElement: This is the element that uses the RadRadialMenu as a context menu.
  • MenuItem: This is the RadialMenuItem that has initiated the command.
  • CommandParameter: The command parameter passed by the RadialMenuItem.

Example

Here is an example demonstrating how to add a custom command to a RadialMenuItem. First, you can create a custom class that implements the ICommand interface.

You can access the RadRadialMenu control through an alias pointing to the Telerik.UI.Xaml.Controls.Navigation namespace: xmlns:navigation="using:Telerik.UI.Xaml.Controls.Navigation"

Example 1: Custom RadialMenuItem Command

public class CustomItemCommand : ICommand 
{ 
    public bool CanExecute(object parameter) 
    { 
        var item = parameter as RadialMenuItemContext; 
 
        // perform custom logic here 
 
        return true; 
    } 
 
    public void Execute(object parameter) 
    { 
        var context = parameter as RadialMenuItemContext; 
        var target = context.TargetElement; 
        var item = context.MenuItem; 
        var commandParameter = context.CommandParameter; 
 
        // perform custom logic here 
    } 
 
    public event EventHandler CanExecuteChanged; 
} 
The next step is to add an instance of the custom command class to the Resources of the Page.

Example 2: Create Instance of the Custom Command

<Page.Resources> 
    <local:CustomItemCommand x:Key="customCommand"/> 
</Page.Resources> 
What's left is to bind the Command property of the RadialMenuItem to the instance of the custom command.

Example 3: Bind the RadRadialMenu

<TextBox Text="Some Text">   
    <navigation:RadRadialContextMenu.Behavior> 
        <navigation:RadialMenuTriggerBehavior AttachTriggers="Focused" /> 
    </navigation:RadRadialContextMenu.Behavior> 
 
    <navigation:RadRadialContextMenu.Menu> 
        <navigation:RadRadialMenu> 
            <navigation:RadialMenuItem Header="Item 1" Command="{StaticResource customCommand}"/> 
            <navigation:RadialMenuItem Header="Item 2" Command="{StaticResource customCommand}"/> 
        </navigation:RadRadialMenu> 
    </navigation:RadRadialContextMenu.Menu> 
</TextBox> 
In this article
Not finding the help you need?