Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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.2.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