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

Generating Diagrams from a Data Source

  • 3 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.


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




(via DiagramDataBindingControllerBase.DataSource)

Specifies the path to a collection of diagram items.


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


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


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


Limitations DiagramItem bindings can only get values from strongly typed objects. Therefore, to bind the diagram to a DataSet or DataTable source, handle the DiagramDataBindingControllerBase.UpdateItem event.


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.


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; }
 public Form1() {
    ViewModel viewModel = new ViewModel();
    diagramDataBindingController1.GenerateItem += DiagramDataBindingController1_GenerateItem;
    diagramDataBindingController1.DataSource = viewModel.Items;
    diagramDataBindingController1.KeyMember = "Id";
    diagramDataBindingController1.ConnectorsSource = viewModel.Connections;
    diagramDataBindingController1.ConnectorFromMember = "From";
    diagramDataBindingController1.ConnectorToMember = "To";
    diagramDataBindingController1.LayoutKind = DiagramLayoutKind.Circular;
private void DiagramDataBindingController1_GenerateItem(object sender, DiagramGenerateItemEventArgs e) {
    var item = new DiagramShape {
        X = 27,
        Width = 75,
        Height = 50,
        Shape = BasicShapes.Rectangle
    item.Bindings.Add(new DiagramBinding("Content", "Name"));
    e.Item = item;