How to Customize or Remove RadPane's Menu
The purpose of this tutorial is to show you how to customize RadPane's menu.
For more information about the RadPane structure, read here. If you want to learn more about RadPane's menu, read this one.
Customizing RadPane's Menu
To add custom commands to RadPane's menu, you should perform the following steps:
-
You can create a custom class CustomRadDockingCommands. Inside, you can create a singleton property of type Telerik.Windows.Controls.RoutedUICommand. Example 1 demonstrates how you can do that.
Example 1: Create Singleton command property
-
Create a custom DataTemplate by using the Telerik's RadContextMenu and RadMenuItem controls. You can use either the built-in RadDockingCommands or create a custom one - both approaches are demonstrated in this topic. Set the created DataTemplate to RadPane's ContextMenuTemplate property. Example 2 show how to set RadPane's ContextMenuTemplate property.
Example 2: Custom DataTemplate for the ContextMenuTemplate property
-
You should implement your custom logic in the OnCloseAllPanesButThis and OnCloseAllPanesButThisCanExecute methods. They specify whether the command can be executed and what action is performed, when it is executed. Example 3 demonstrates sample logic for the command methods.
Example 3: Implement Execute and CanExecute methods
-
Your menu command is ready and you have a custom DataTemplate, which is set to the ContextMenuTemplate property. The next step is to register your custom command by using the Telerik.Windows.Controls.CommandManager class in the CustomRadDockingCommands constructor. Example 4 shows the final structure of the CustomRadDockingCommands class.
Example 4: Register CloseAllPanesButThisCommand custom command
Run your demo. RadPane's menu should look like the snapshot below.
Removing RadPane's Menu
In order to remove RadPane's Menu, you should set RadPane's ContextMenuTemplate property to null (respectively {x:Null} in XAML).