Giter Site home page Giter Site logo

devexpress-examples / how-to-create-items-with-custom-content-in-diagramcontrol-t395119 Goto Github PK

View Code? Open in Web Editor NEW
1.0 56.0 1.0 80 KB

Create diagram items with custom elements and register these items in the toolbox

License: Other

C# 53.59% Visual Basic .NET 46.41%
dotnet dxdiagram wpf xpf

how-to-create-items-with-custom-content-in-diagramcontrol-t395119's Introduction

WPF DiagramControl - Create Items with Custom Content

This example demonstrates how to create diagram items with custom elements and register these items in the toolbox.

image

DiagramControl shapes can display only string content. To add custom elements to diagram items, use DiagramContentItem objects with the specified ContentTemplate property:

<Style x:Key="formattedTextContentItem" TargetType="dxdiag:DiagramContentItem">
    <Setter Property="ContentTemplate">
        <Setter.Value>
            <DataTemplate>
                <!-- ... -->
            </DataTemplate>
        </Setter.Value>
    </Setter>
</Style>

Create a DiagramStencil object and call its RegisterTool method with the FactoryItemTool object as a parameter to register the created DiagramContentItem in the toolbox:

DiagramStencil stencil = new DiagramStencil("CustomTools", "Content Item Tools");

stencil.RegisterTool(new FactoryItemTool(
    id: "Text",
    getName: () => "Text",
    createItem: diagram => new DiagramContentItem() {
        CustomStyleId = "formattedTextContentItem"
    },
    defaultSize: new Size(230, 110), 
    isQuick: true
));

Call the DiagramToolboxRegistrator.RegisterStencil method to register the stencil:

DiagramToolboxRegistrator.RegisterStencil(stencil);

To deserialize the DiagramContentItem, specify its CustomStyleId property. This property accepts the applied style's key.

Files to Review

Documentation

More Examples

how-to-create-items-with-custom-content-in-diagramcontrol-t395119's People

Contributors

alexgoon avatar alexilia avatar andreyslabov avatar devexpressexamplebot avatar goncharovgit avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

alexgoon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.