[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Collapse]Layout Management
   [Collapse]Dock Windows
    [Expand]Getting Started
    [Expand]Dock Items
    [Expand]Layout Items
    [Expand]Runtime Features
      Saving and Restoring the Layout of Dock Panels and Controls
      Managing Dock Panels in Code
      MVVM Support - Building Dock UI
      Move Panels Between DockLayoutManager Instances
      WPF and WinForms Interoperation Limitations
   [Expand]Tile and Layout
   [Expand]Tab Control
    Book Control
    Workspace Manager
  [Expand]Windows Modern UI
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Managing Dock Panels in Code

This topic describes how to manage Dock Items (perform operations such as creating, removing, docking and auto-hiding panels, and making panels floating) in code, using DockLayoutManager.DockController methods.

Expanded Creating and Removing Panels

You can create a new dock panel (LayoutPanel) by calling the DockControllerBase.AddPanel method of the DockLayoutManager.DockController. The following example shows how to create and dock a panel at the right edge of the DockLayoutManager. (This method allows you to dock a panel to any other edge as well - top, bottom or left.)

If you use DockType.None as the type parameter, the AddPanel method creates a new instance of the LayoutPanel class without displaying it anywhere. To display this panel later, use the following methods.

To create a floating panel, use the AddPanel(Point floatLocation, Size floatSize) method overload, which allows the float panel size and location to be specified.

You can also create a new LayoutPanel using its constructor. The panel will not appear on screen until you dock it to a DockLayoutManager. To dock a panel, you can use the DockControllerBase.Dock and DockControllerBase.Insert methods as well.

You can delete a LayoutPanel in code by calling the DockControllerBase.RemovePanel method:

Expanded Moving Panels

To move a dock panel to a new position (for instance, next to another dock panel) use the DockControllerBase.Dock method. This method allows you to define the target layout item and the docking type:


Depending on the orientation of the target LayoutGroup items and the type parameter of the Dock method, the panel being moved is docked either to the LayoutGroup or next to it.

The DockControllerBase.Dock method also allows you to add a dock panel to a TabbedGroup by setting the type parameter to DockType.Fill.

The same goal can be achieved by docking a LayoutPanel to another LayoutPanel that is already in the TabbedGroup. The relative position can be specified by the type parameter:

It is possible to merge two LayoutPanels into a TabbedGroup by using DockControllerBase.Dock and setting the type parameter to DockType.Fill:


If the target LayoutPanel is already in a TabbedGroup, the docking LayoutPanel will be appended to this TabbedGroup.

You can also insert a panel into any LayoutGroup descendant (TabbedGroup, AutoHideGroup or FloatGroup) by calling the DockControllerBase.Insert method. The method parameters specify the target layout item and position.

Expanded Floating Panels

To make an existing docked panel floating, use the DockControllerBase.Float method:

Float panels are displayed within floating windows represented by FloatGroup objects. For FloatGroup objects to be displayed, they must be added to the DockLayoutManager.FloatGroups collection. The Float method in the above example automatically creates a new FloatGroup, adds it to the FloatGroups collection, and adds the LayoutPanel to this FloatGroup.

Alternatively, you can create a float group manually and add a LayoutPanelto this group. Ensure that the newly created FloatGroup is added to the DockLayoutManager.FloatGroups collection:

It is possible to use the DockControllerBase.Dock and DockControllerBase.Insert methods to add a LayoutPanel to a FloatGroup. The Insert method allows you to define the position within the FloatGroup in which the LayoutPanel is inserted:

Expanded Auto-Hide

Auto-hidden panels are normally hidden from view, and appear only when hovering over the panel's label. A panel can be auto-hidden at the top, left, bottom or right edge of the DockLayoutManager. When a panel is auto-hidden, it is placed into an AutoHideGroup object that is docked to the corresponding edge. To be displayed, an AutoHideGroup must be added to the DockLayoutManager.AutoHideGroups collection.

You can call the DockControllerBase.Hide method to make an existing LayoutPanel auto-hidden.

A panel can also be auto-hidden by creating an instance of the AutoHideGroup class manually, and adding it to a DockLayoutManager.AutoHideGroups collection. Set the AutoHideGroup.DockType property (set to Dock.Left by default) to place the AutoHideGroup at a specific edge of the DockLayoutManager.

The following methods let you add a LayoutPanel to an existing AutoHideGroup: DockControllerBase.Dock and DockControllerBase.Insert.

Expanded Panel Visibility and Closing/Restoring Panels

An existing panel can be closed by calling the DockControllerBase.Close method, and restored to its previous position using the DockControllerBase.Restore method:

The DockControllerBase.Close method moves a closed panel to the DockLayoutManager.ClosedPanels collection, or deletes the reference to this panel from DockLayoutManager.DockLayoutManager, depending on the DockLayoutManager.ClosingBehavior and BaseLayoutItem.ClosingBehavior properties.

DockLayoutManager.ClosingBehavior determines the close behavior for all panels in DockLayoutManager, but it is possible to override this behavior for each panel with the BaseLayoutItem.ClosingBehavior property. The DockLayoutManager.ClosingBehavior property determines a panel's close behavior only if the BaseLayoutItem.ClosingBehavior is set to Default.

A closed panel can also be restored to a new position via the DockControllerBase.Dock method or DockControllerBase.Insert method.

The DockLayoutManager has a Closed Panels Bar, which provides access to closed panels. Each panel added to the DockLayoutManager.ClosedPanels collection appears in the Closed Panels Bar as a button.

The position and visibility of the Closed Panels Bar can be set via the DockLayoutManager.ClosedPanelsBarPosition and DockLayoutManager.ClosedPanelsBarVisibility properties:

In some cases, you may wish to manipulate panel visibility with the Visibility property. To hide a panel, set this property to Visibility.Hidden or Visibility.Collapsed. When you set this property to Visibility.Hidden, the panel is hidden, and space for the element is reserved in the layout. Using Visibility.Collapsed allows you to hide a panel without reserving space for it in the layout.

The Visibility property works in the same way as the UIElement.Visibility property. A LayoutPanel hidden by this property cannot be restored via the DockControllerBase.Restore method.

Expanded See Also

Is this topic helpful?​​​​​​​