How to Close the Active Pane with a Key Combination
Environment
Product Version | 2020.3.916 |
Product | RadDocking for WPF |
Description
How to close the active pane with a key combination.
Solution
As of R3 2020, you can use the new ClosePane command to close the currently active pane. The command accepts a parameter of type ClosePaneMode which has three possible values:
- DocumentPanes: The active document pane is closed or if there is no active, the first selected document pane is closed.
- NonDocumentPanes: The active non-document pane is closed, if any.
- ActivePanes: The active pane is closed, if any.
If no parameter is passed, the command will close the currently active pane, if there is such.
Example 1: Binding the ClosePane to Ctrl+F4 for a single RadDocking instance
<telerik:RadDocking>
<!-- ... -->
<telerik:RadDocking.InputBindings>
<KeyBinding Command="telerik:RadDockingCommands.ClosePane" CommandParameter="DocumentPanes" Key="F4" Modifiers="Ctrl" />
</telerik:RadDocking.InputBindings>
</telerik:RadDocking>
Example 2: Binding the ClosePane to Ctrl+F4 for all RadDocking controls in the application
public App()
{
KeyBinding keyBinding = new KeyBinding(RadDockingCommands.ClosePane, new KeyGesture(Key.F4, ModifierKeys.Control)) { CommandParameter = ClosePaneMode.DocumentPanes };
CommandManager.RegisterClassInputBinding(typeof(RadDocking), keyBinding);
}