Articles in this section
Category / Section

How to edit the context menu for DockWindow in DockingManager?

1 min read

  Context menu of DockWindow can be customized using the

  DockWindowContextMenuItemStyle of DockingManager with Target Type as

  CustomMenuItem.

  The same has been explained in the following code:

  XAML:

//Code Explains How to customize the DockWindowContextMenuitem style in
 DockingManager
<Window                
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" x:Class="DockWindow_CustomMenuitem.MainWindow"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style x:Key="custom" TargetType="{x:Type syncfusion:CustomMenuItem}">
<Setter Property="Background" Value="Yellow"></Setter>
<Setter Property="Foreground" Value="Green"></Setter>
</Style>
</Window.Resources>
<Grid>
<syncfusion:DockingManager Name="Docking"
UseDocumentContainer="True" 
DockWindowContextMenuItemStyle="{StaticResource custom}">
<syncfusion:DockingManager.CustomMenuItems>
<syncfusion:CustomMenuItemCollection>
<syncfusion:CustomMenuItem Name="customitem1" Header="custom1"></syncfusion:CustomMenuItem>
<syncfusion:CustomMenuItem Name="customitem2" Header="custom2" />
<syncfusion:CustomMenuItem Name="customitem3" Header="custom3" />
</syncfusion:CustomMenuItemCollection>
</syncfusion:DockingManager.CustomMenuItems>
<ContentControl syncfusion:DockingManager.Header="Dock">
</ContentControl>
<ContentControl syncfusion:DockingManager.Header="Dock1"></ContentControl>
</syncfusion:DockingManager>
</Grid>
</Window>
 

    C#:

  //Code Explains How to customize the DockWindowContextMenuitem style in DockingManager   
  namespace DockWindow_CustomMenuitem
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Style style = this.FindResource("custom") as Style;
            Docking.DockWindowContextMenuItemStyle = style;
            customitem1.Header = "custommenu1";
            customitem2.Header = "custommenu2";
            customitem3.Header = "custommenu3";
        }
    }
}

 

  Output:

                

                     C:\Users\Ashok.Murugesan\Desktop\Switchmode\DockWindow-Contextmenuitem.png

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied