Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to create a DiagramShape descendant and serialize its properties

$
0
0
This example demonstrates how to serialize custom data using DiagramControl's serialization mechanism. In the example, the Content property of diagram shapes is loaded from data objects every time the diagram is shown. To associate shapes with data objects, the DatabaseObjectID property is added at the DiagramShape descendant level. To serialize this property along with standard DiagramShape properties, perform the following steps:

Note:
In certain scenarios, it is easier to use the DiagramShape.Tag property to store custom data without creating DiagramShape descendants. In this case, no further steps are needed as the Tag property is serialized by default.

1) Mark your custom property with the XtraSerializableProperty attribute:
[C#]
[Browsable(false),XtraSerializableProperty]publicintDatabaseObjectID{get;set;}
Set the Browsable(false) attribute if you don't want to display your custom property in DiagramControl's property editor.

2) Call the ItemTypeRegistrator.Register method to register your custom shape type for serialization:
[C#]
DiagramControl.ItemTypeRegistrator.Register(typeof(DiagramShapeEx));

Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>