Item Template Designer
- 2 minutes to read
The Item Template Designer is a design-time tool that is used to define the appearance of items and connectors for diagrams generated from a data source (DiagramDataBindingController and DiagramOrgChartController).
Invoking the Designer
To invoke the Item Template Designer, switch to the design view and invoke the diagram's smart tag. Switch to the MVVM behaviors and Services tab and select the Run Template Designer item within the Properties group of a corresponding behavior.
Customizing Items and Binding to Data
To define the appearance of connectors, drag a connector to the canvas and apply the desired settings to it.
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 the Text and Image elements. Items can be bound to data fields using the Item Data Binding Editor. To invoke it, double-click an item or click the item within it. To simply bind an item to a data field, type the field name.
The Save changes to the source option specifies whether to apply the TwoWay binding mode, causing changes in the diagram item's text to automatically update the data field value. This option is only in effect if the behavior's DiagramDataBindingControllerBase.EnableNotificationToSource property is set to true.
To build complex binding expressions, use the Criteria Language Syntax. The Save changes to the source option is only available for simple binding expressions.
Selecting Templates in Code-Behind
The uppermost connector and diagram item defined in code-behind in the DiagramDataBindingControllerBase.TemplateDiagram are used as the template for the connectors and diagram items representing data objects.
To implement custom logic for choosing the template, specify the template names using the DiagramItem.TemplateName property. Then handle the DiagramDataBindingControllerBase.GenerateItem and DiagramDataBindingControllerBase.GenerateConnector events and specify the name of the desired template as the event's CreateItemFromTemplate/CreateConnectorFromTemplate method parameter.