Skip to main content
A newer version of this page is available. .

Generating Diagrams from a Data Source

  • 2 minutes to read

The DiagramDataBindingController class provides the data binding functionality for the DiagramControl. To bind the DiagramControl to data, open its Smart Tag panel and select Add DataBindingController.

Diagram Data Controllers

To configure the data source, go to the diagramDataBindingController‘s Smart Tag.

DiagramDataBindingController1

The following table lists the properties used to map a diagram to data.

Member

Description

DiagramDataBindingController.DataSource

(via DiagramDataBindingControllerBase.DataSource)

Specifies the path to a collection of diagram items.

DiagramDataBindingController.ConnectorsSource

Specifies the path to a collection of objects that represent connectors.

DiagramDataBindingController.ConnectorFromMember

Specifies the name of the data field that identifies the item to use as a connector’s start item.

DiagramDataBindingController.ConnectorToMember

Specifies the name of the data field that identifies the item to use as a connector’s end item.

Note

Limitations The DiagramDataBindingController can only get values from strongly typed objects. Binding to dynamic properties is not supported.

Tip

The Item Template Designer allows you to design templates for diagram items and connectors at design time.

The following example demonstrates the DiagramControl bound to sample data.

DataBindingBehaviorExample


public class ViewModel {
    public List<Item> Items { get; set; }
    public List<Link> Connections { get; set; }
    public ViewModel() {
        Items = new List<Item>();
        for (int i = 0; i < 5; i++)
            Items.Add(new Item { Id = i, Name = "Item " + i });
        Connections = new List<Link>();
        for (int i = 0; i < 4; i++)
            Connections.Add(new Link { From = Items[i].Id, To = Items[i + 1].Id });
        Connections.Add(new Link { From = Items[4].Id, To = Items[0].Id });
    }
}
public class Item {
    public int Id { get; set; }
    public string Name { get; set; }
}

public class Link {
    public object From { get; set; }
    public object To { get; set; }
}