Search
Custom Item Types

You can create your own item types by deriving the DiagramNode and DiagramLink classes or their successors such as TableNode, ContainerNode and so on. You can add custom data fields to the diagram items, and implement custom visualization and interaction functionality.

Serialization

If you add custom fields to your item class, you will probably want their values saved when saving diagram files, and restored when loading files. To enable this, override the SaveTo and LoadFrom methods of the DiagramItem class, and you can use BinaryWriter and BinaryReader objects to implement binary serialization. For XML serialization, you must implement the SaveToXml and LoadFromXml methods.

Clipboard operations

You must implement the Clone method in order to enable CopyToClipboard and PasteFromClipboard to work with your custom item type, If Clone is not implemented, you will get an instance of the base class created for the pasted item, and this could lead to an exception when the base class deserialization code tries to load the item state from a data stream created by the derived class. If your class has any custom fields, it must also implement the SaveToXml and LoadFromXml methods for proper serialization.

Rendering

If you need to provide custom rendering for your items, override the Draw method. In this way, you can render your item on a DrawingContext surface.

User interaction

To enable drawing of items from a custom class, set the Behavior property of the diagram view to Custom, and set the CustomNodeType or CustomLinkType property to the Type object that corresponds to your class. If you need to change how items handle user interaction while they are being initially created, implement the StartCreate, UpdateCreate and CompleteCreate methods. In order to change how items respond to user interaction while they are being modified, implement the StartModify, UpdateModify and CompleteModify methods.