Item Template Designer

  • 2 min to read

The Item Template Designer is a design-time tool used to define the appearance of items and connectors for diagrams generated from a data source (DiagramDataBindingBehavior and DiagramOrgChartBehavior).

Invoking the Designer

To invoke the Item Template Designer, switch to the design view and invoke the diagram's smart tag menu. Switch to the MVVM behaviors and Services tab and select Run Template Designer within the Properties group of the corresponding behavior.

Run Template Designer

Customizing Items and Binding to Data

To define the appearance of connectors, drag a connector to the canvas and apply the desired settings.

To define the appearance of items representing data objects, drag a template from the Template Designer category of the toolbox onto the canvas and customize it as needed. Individual data fields are represented by Text and Image elements. You can bind items to data fields using the Item Data Binding Editor. To invoke it, double-click an item or click the template designer data icon item within the Editor. To bind an item to a data field, type the field name.

Item Data Binding Editor

The Save changes to the source option specifies whether to apply the TwoWay binding mode, which automatically updates the data field value based on changes in the diagram item's text. This option is only in effect if the behavior's DiagramDataBindingBehaviorBase.EnableNotificationToSource property is set to true.

NOTE

The Save changes to the source option is only available for simple binding expressions. To build complex binding expressions, use the Criteria Language Syntax.

Selecting Templates in Code-Behind

The uppermost connector and diagram item defined in code-behind in the DiagramDataBindingBehaviorBase.TemplateDiagram are used as the template for the connectors and diagram items representing data objects.

You can use the DiagramDataBindingBehaviorBase.ItemTemplateSelector and DiagramDataBindingBehaviorBase.ConnectorTemplateSelector properties to implement custom logic for template selection.

Alternatively, specify template names using the DiagramItem.TemplateName property. Then handle the DiagramDataBindingBehaviorBase.GenerateItem and DiagramDataBindingBehaviorBase.GenerateConnector events, and specify the name of the desired template as the event's CreateItemFromTemplate/CreateConnectorFromTemplate method parameter.