[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
  Prerequisites
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Collapse]Diagram Control
    Getting Started
   [Expand]Diagram Control
   [Expand]End-User Interaction
   [Collapse]Diagram Items
     Shapes
     Default Shapes
     Connectors
     Containers
     Images
     SVG Shapes
     Items with Custom Content
     Creating Shapes and Containers Using Shape Templates
     Managing Items Interaction
   [Expand]Automatic Layout
   [Expand]Data Binding
    Themes and Styles
    Printing and Exporting
    Saving and Loading Diagrams
   [Expand]Examples
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Containers

Expanded Overview

You can use containers to group diagram items.

DiagramContainer class objects represent containers.

When you move, copy or delete a container, these actions also apply to its contents.

Expanded Create a Container

Users can select the corresponding ribbon item on the Insert ribbon page to add containers.

To add a container in code, create a DiagramContainer object and add it to the DiagramControl.Items or DiagramContainerBase.Items collection. See the example below.

Expanded Content

Any item can be placed within a container, including another container. To add or remove items, drag them in or out of the container. The container automatically adjusts its width and height to fit the contents. The DiagramContainerBase.AdjustBoundsBehavior property manages this behavior.

The DiagramContainerBase.Items property provides access to the collection of diagram items placed within the container. For items within a container, the DiagramItem.Position property specifies the coordinates of the item's upper left corner relative to the container.

Note

Do not add DiagramConnector items to the DiagramContainerBase.Items collection. Instead, add connector items to the DiagramControl.Items collection and use the DiagramConnector.BeginItem and DiagramConnector.EndItem properties to connect them to items that reside in a container.

Expanded Header and Styles

Each container has a header. To edit the header, double-click the container and toggle the header visibility via the Show Header Ribbon item. This item is within the Container Tools ribbon category that appears when a container is selected. Additionally, users can customize the header and content padding (the DiagramContainer.HeaderPadding and Padding properties) and select the container style.

You can edit the header in code by setting the DiagramContainer.Header property and hide it by setting the DiagramContainer.ShowHeader property to false.

To set the container style in code, set the DiagramContainer.Shape property to a DevExpress.Diagram.Core.StandardContainers value. See the example below.

Expanded Proportional Resizing

Users can drag the corner selection handles to resize the container. To change the aspect ratio, hold SHIFT while dragging a corner selection handle or drag one of the side selection handles. To disable the proportional resizing, set the DiagramControl.EnableProportionalResizing to false.

Expanded Collapsing Containers

Set the DiagramControl.AllowCollapseContainers property to true to show the Expand/Collapse button in container headers. End-users can display or hide container content by clicking this button. Use the DiagramContainer.CanCollapse property to control the collapse functionality for individual containers. The DiagramContainer.CollapseContainerButtonSize and DiagramContainer.CollapseContainerButtonPadding properties specify the size and padding of the expand/collapse button.

Expanded Hiding Subordinate Items

The container's DiagramItem.CanHideSubordinates property specifies whether to display the expand-collapse button below the container that is used to show/hide the container's subordinate items. The DiagramItem.AreSubordinatesVisible property returns whether the subordinate items are currently shown.

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