Skip to main content

DiagramContentItem Class

Represents a diagram item with custom content.

Namespace: DevExpress.Xpf.Diagram

Assembly: DevExpress.Xpf.Diagram.v24.1.dll

NuGet Package: DevExpress.Wpf.Diagram


public class DiagramContentItem :


Simple shapes in a DiagramControl display only their content as an editable string. Use the DiagramContentItem class to add custom elements to diagram items. DiagramContentItem has the DiagramContentItem.ContentTemplate property, which can be used to put any elements into the item.

<Style x:Key="formattedTextContentItem" TargetType="dxdiag:DiagramContentItem">
    <Setter Property="ContentTemplate">

To register a DiagramContentItem in the toolbox, use the DiagramStencil.RegisterTool method with FactoryItemTool as a parameter:

stencil.RegisterTool(new FactoryItemTool(
    () => "Calendar",
    diagram => new DiagramContentItem() {
        CustomStyleId = "formattedTextContentItem"
    new Size(230, 110), true));

After that, register the stencil using DiagramToolboxRegistrator.RegisterStencil.


To properly deserialize a DiagramContentItem, it’s necessary to set its DiagramItem.CustomStyleId property, which accepts a key of a Style applied to the item.


The following example shows how to create diagram items that display custom content.

View Example

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Windows

Namespace DXDiagram.ContentItem
    Public Class ButtonItemModel
        Public Sub ShowMessage()
            MessageBox.Show("This command has been created by our POCO machanism based on the ShowMessage method")
        End Sub
    End Class
End Namespace

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DiagramContentItem class.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also