Skip to main content

DiagramDataBindingBehavior.DiagramConnectorAdding Event

Fires each time the user draws a new connector in a data-bound diagram.

Namespace: DevExpress.Xpf.Diagram

Assembly: DevExpress.Xpf.Diagram.v24.1.dll

NuGet Package: DevExpress.Wpf.Diagram

Declaration

public event EventHandler<DiagramDiagramConnectorAddingEventArgs> DiagramConnectorAdding

Event Data

The DiagramConnectorAdding event's data class is DevExpress.Xpf.Diagram.DiagramDiagramConnectorAddingEventArgs.

Remarks

Handle the DiagramConnectorAdding event so that DiagramDataBindingBehavior can add a corresponding data item to the bound source. See the example below:

public class ClassData {
    public string ClassName { get; set; }
    public ClassType Type { get; set; }
}
public enum ClassType {
    Class,
    Interface,
    AbstractClass,
}

public class ConnectionData {
    public object ConnectedFrom { get; set; }
    public object ConnectedTo { get; set; }
}

private void DiagramDataBindingBehavior_DiagramConnectorAdding(object sender, DevExpress.Xpf.Diagram.DiagramDiagramConnectorAddingEventArgs e) {
    if (e.Connector.BeginItem != null && e.Connector.EndItem != null) {
        e.Connector.Stroke = Brushes.Red;
        e.DataItem = new ConnectionData() { ConnectedFrom = ((ClassData)(((DiagramContainer)e.Connector.BeginItem)).DataContext).ClassName, ConnectedTo = ((ClassData)(((DiagramContainer)e.Connector.EndItem)).DataContext).ClassName };
    }
}
See Also