We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to hide specific menu items in default context menu of the TabItemExt in WPF DockingManager?

Platform: WPF |
Control: DockingManager |
Published Date: May 30, 2018 |
Last Revised Date: August 3, 2021

You can hide the selected context menu according to the requirement in WPF DockingManager. The following screenshot shows the default context menu of the document child.

 

Default context menu of WPF DockngManager

For instance, to show only the close context menu of the document child in the DockingManager, you need to hide all the other default context menu items. This can be done by using the Boolean property of the DockingManager that has a naming convention, Show + Nameof theContextMenuItem. By disabling this property, you can hide the unnecessary context menu items. 

The following code example demonstrates the same.

XAML

<Window x:Class="TabControl.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
        xmlns:shared="clr-namespace:Syncfusion.Windows.Shared;assembly=Syncfusion.Shared.WPF"
        xmlns:local="clr-namespace:Syncfusion.Windows.Tools.Controls;assembly=Syncfusion.Tools.Wpf"  
        Title="MainWindow" Height="350" Width="525">
    <Grid x:Name="Grid1">
       <syncfusion:DockingManager x:Name="DockingManager1" UseDocumentContainer="True"  ContainerMode="TDI" >
     <ContentControl x:Name="Content1" syncfusion:DockingManager.Header="Tab1"
                           syncfusion:DockingManager.State="Document"
                           syncfusion:DockingManager.ShowCloseAllButThisMenuItem="False"
                           syncfusion:DockingManager.ShowCloseAllMenuItem="False"
                           syncfusion:DockingManager.ShowFloatingMenuItem="False"
                           syncfusion:DockingManager.ShowDockableMenuItem="False"
                           syncfusion:DockingManager.ShowTabbedMenuItem="False"
                          syncfusion:DockingManager.ShowVerticalTabGroupMenuItem="False"
                    syncfusion:DockingManager.ShowHorizontalTabGroupMenuItem="False"
                        syncfusion:DockingManager.CanDock="False"
                        syncfusion:DockingManager.ShowDocumentMenuItem="False"            
       </ContentControl>          
       <ContentControl x:Name="Content2" syncfusion:DockingManager.Header="Tab2"
                       syncfusion:DockingManager.State="Document"                     
                       ></ContentControl>
        </syncfusion:DockingManager>     
    </Grid>
</Window>

C#

using Syncfusion.Windows.Tools.Controls;
using Syncfusion.Windows.Tools.Controls;
namespace TabControl
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml.
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {        
            InitializeComponent();
            DockingManager DockingManager1 = new DockingManager();
            DockingManager1.UseDocumentContainer = true;
            ContentControl Content1 = new ContentControl();
            DockingManager.SetHeader(Content1, "Tab1");
            DockingManager.SetState(Content1, DockState.Document);
            DockingManager.SetShowCloseAllMenuItem(Content1, false);
            DockingManager.SetShowCloseAllButThisMenuItem(Content1, false);
            DockingManager.SetShowDockableMenuItem(Content1, false);
            DockingManager.SetShowFloatingMenuItem(Content1, false);
            DockingManager.SetShowTabbedMenuItem(Content1, false);
            DockingManager.SetShowDocumentMenuItem(Content1, false);
            DockingManager.SetShowHorizontalTabGroupMenuItem(Content1, false);
            DockingManager.SetShowVerticalTabGroupMenuItem(Content1, false);
            DockingManager1.Children.Add(Content1);
            ContentControl Content2 = new ContentControl();
            DockingManager.SetHeader(Content2, "Tab2");
            DockingManager.SetState(Content2, DockState.Document);
            DockingManager1.Children.Add(Content2);
            Grid1.Children.Add(DockingManager1);
        }
    }
}

 

The following screenshot shows only the close context menu item in the document child of the DockingManager.

WPF DockingManager displays close context menu item

 

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile