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

How to: Create Items with Custom Content in DiagramControl

$
0
0

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

[XAML]
<Stylex:Key="calendarContentItem"TargetType="dxdiag:DiagramContentItem"><SetterProperty="ContentTemplate"><Setter.Value><DataTemplate> ...</DataTemplate></Setter.Value></Setter></Style>

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

[C#]
stencil.RegisterTool(newFactoryItemTool("Calendar",()=>"Calendar",diagram=>newDiagramContentItem(){CustomStyleId="calendarContentItem",ConnectionPoints=newDiagramPointCollection(new[]{newPoint(0.05, 0.5),newPoint(0.95, 0.55)})},newSize(200, 200),true));

After that, register the stencil using DiagramToolboxRegistrator.RegisterStencil.
Please note that to properly deserialize DiagramContentItem, it's necessary to set its CustomStyleId property, which accepts a key of a Style applied to the item.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



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