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

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


Product Version 2019.3.917
Product RadDocking for WPF


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.


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

    private void TextBlock_ContextMenuOpening(object sender, ContextMenuEventArgs e) 
        var element = sender as FrameworkElement; 
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

    <TextBlock Focusable="True" Text="Open the Context menu with right klick" ContextMenuOpening="TextBlock_ContextMenuOpening"> 
                <MenuItem Header="MenuItem1" /> 
                <MenuItem Header="MenuItem2" /> 
In this article