New to Telerik UI for WPFStart a free 30-day trial

Prevent the Closing of Panes in the Auto-Hide Area When ContextMenu is Opened

Updated on Sep 15, 2025

Environment

Product Version2019.3.917
ProductRadDocking for WPF

Description

In the following solution we are going to demonstrates how to prevent RadPanes from closing in the auto-hide area when a ContextMenu is opened.

Solution

To achieve this requirement you can handle the ContextMenuOpening event of the element to which you've added the ContextMenu (the TextBlock in this case) and focus its content.

Example 1: Subscribe to the ContextMenuOpening event C# private void TextBlock_ContextMenuOpening(object sender, ContextMenuEventArgs e) { var element = sender as FrameworkElement; element.Focus(); }

Please note that in the case of the TextBlock you also need to set its Focusable property to True.

Example 2: Set Focusable to True C# <TextBlock Focusable="True" Text="Open the Context menu with right klick" ContextMenuOpening="TextBlock_ContextMenuOpening"> <TextBlock.ContextMenu> <ContextMenu> <MenuItem Header="MenuItem1" /> <MenuItem Header="MenuItem2" /> </ContextMenu> </TextBlock.ContextMenu> </TextBlock>

In this article
EnvironmentDescriptionSolution
Not finding the help you need?
Contact Support