Back to Devexpress

DiagramOptionsBehavior.Stencils Property

windowsforms-devexpress-dot-xtradiagram-dot-options-dot-diagramoptionsbehavior-cb18e94c.md

latest4.7 KB
Original Source

DiagramOptionsBehavior.Stencils Property

Provides access to the collection of available stencils.

Namespace : DevExpress.XtraDiagram.Options

Assembly : DevExpress.XtraDiagram.v25.2.dll

NuGet Package : DevExpress.Win.Diagram

Declaration

csharp
[Browsable(false)]
[DefaultValue(null)]
public virtual DiagramStencilCollection Stencils { get; set; }
vb
<DefaultValue(Nothing)>
<Browsable(False)>
Public Overridable Property Stencils As DiagramStencilCollection

Property Value

TypeDefaultDescription
DevExpress.Diagram.Core.DiagramStencilCollectionnull

A DevExpress.Diagram.Core.DiagramStencilCollection object that is the collection of available stencils.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to Stencils
DiagramControl

.OptionsBehavior .Stencils

|

Remarks

Use the Stencils property to register new or remove the default stencils.

See the example below.

csharp
var svgStencil = new DiagramStencil("SVGStencilId", "SVGStencilName");
using(var svgStream = File.OpenRead("Shape.svg")) {
    var svgShape = ShapeDescription.CreateSvgShape("SVGShapeId", "SVGShapeName", svgStream);
    svgStencil.RegisterShape(svgShape);
}
diagramControl.Stencils = new DiagramStencilCollection(svgStencil, BasicShapes.Stencil);
vb
Dim svgStencil = New DiagramStencil("SVGStencilId", "SVGStencilName")
Using svgStream = File.OpenRead("Shape.svg")
    Dim svgShape = ShapeDescription.CreateSvgShape("SVGShapeId", "SVGShapeName", svgStream)
    svgStencil.RegisterShape(svgShape)
End Using
diagramControl.Stencils = New DiagramStencilCollection(svgStencil, BasicShapes.Stencil)

If the Stencils property is set to null , the diagram toolbox loads its stencils from the DiagramToolboxRegistrator.Stencils static collection.

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

Note

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.

how-to-create-custom-diagram-containers-and-register-them-in-the-toolbox-and-ribbon-gallery-t466447/CS/XtraDiagram.CreateCustomContainers/Form1.cs#L28

csharp
var customContainersStencil = DiagramStencil.Create(MyContainersStencilName, "Custom Containers", containerDescriptions);
diagramControl1.OptionsBehavior.Stencils = new DiagramStencilCollection(DiagramToolboxRegistrator.Stencils.Concat(new[] { customContainersStencil }));
diagramControl1.SelectedStencils = new StencilCollection(MyContainersStencilName, BasicShapes.StencilId);

how-to-create-custom-diagram-containers-and-register-them-in-the-toolbox-and-ribbon-gallery-t466447/VB/XtraDiagram.CreateCustomContainers/Form1.vb#L28

vb
Dim customContainersStencil = DiagramStencil.Create(MyContainersStencilName, "Custom Containers", containerDescriptions)
diagramControl1.OptionsBehavior.Stencils = New DiagramStencilCollection(DiagramToolboxRegistrator.Stencils.Concat({customContainersStencil}))
diagramControl1.SelectedStencils = New StencilCollection(MyContainersStencilName, BasicShapes.StencilId)

See Also

DiagramOptionsBehavior Class

DiagramOptionsBehavior Members

DevExpress.XtraDiagram.Options Namespace