Class Edge
Represents a connection between two nodes. Uses a Definition (immutable) + State (mutable) composition pattern. Implements ICanvasElement for unified element handling.
public class Edge : ICanvasElement, INotifyPropertyChanged
- Inheritance
-
Edge
- Implements
- Inherited Members
- Extension Methods
Remarks
The edge's structural properties (Source, Target, ports, type, markers) are stored in the Definition record. Runtime state (selection, waypoints) is stored in the State object.
For backward compatibility, pass-through properties are provided that delegate to either Definition or State as appropriate.
Constructors
Edge()
Creates an edge with default definition. For backward compatibility.
public Edge()
Edge(EdgeDefinition, IEdgeState?)
Creates an edge with the specified definition and optional state.
public Edge(EdgeDefinition definition, IEdgeState? state = null)
Parameters
definitionEdgeDefinitionThe immutable edge definition.
stateIEdgeStateThe mutable edge state. If null, a new EdgeState is created.
Properties
AutoRoute
Whether automatic routing is enabled.
public bool AutoRoute { get; set; }
Property Value
Definition
The immutable definition of this edge (identity, connections, visual type).
Use with expressions to modify: edge.Definition = edge.Definition with { Label = "x" };
public EdgeDefinition Definition { get; set; }
Property Value
Id
Unique identifier for the edge. Immutable - to change, replace the Definition.
public string Id { get; }
Property Value
IsLocked
Whether this edge is locked, preventing deletion and reconnection via UI.
public bool IsLocked { get; set; }
Property Value
Remarks
When true, the edge cannot be deleted or reconnected through user interaction. Programmatic changes are still allowed.
IsSelectable
Whether this edge can be selected by user interaction.
public bool IsSelectable { get; set; }
Property Value
IsSelected
Whether this edge is currently selected.
public bool IsSelected { get; set; }
Property Value
IsVisible
Gets or sets whether this edge is visible in the canvas. Delegates to State.IsVisible.
public bool IsVisible { get; set; }
Property Value
Label
Optional label for the edge.
public string? Label { get; set; }
Property Value
MarkerEnd
The marker at the end of the edge.
public EdgeMarker MarkerEnd { get; set; }
Property Value
MarkerStart
The marker at the start of the edge.
public EdgeMarker MarkerStart { get; set; }
Property Value
Source
The ID of the source node. To modify, use: edge.Definition = edge.Definition with { Source = "x" };
public string Source { get; set; }
Property Value
SourcePort
The ID of the source port. To modify, use: edge.Definition = edge.Definition with { SourcePort = "x" };
public string SourcePort { get; set; }
Property Value
State
The mutable runtime state of this edge (selection, waypoints).
public IEdgeState State { get; set; }
Property Value
Style
Visual style for the edge including colors, dash patterns, and effects.
public EdgeStyle? Style { get; set; }
Property Value
Target
The ID of the target node. To modify, use: edge.Definition = edge.Definition with { Target = "x" };
public string Target { get; set; }
Property Value
TargetPort
The ID of the target port. To modify, use: edge.Definition = edge.Definition with { TargetPort = "x" };
public string TargetPort { get; set; }
Property Value
Type
The visual type of the edge. To modify, use: edge.Definition = edge.Definition with { Type = EdgeType.Straight };
public EdgeType Type { get; set; }
Property Value
Waypoints
Optional waypoints for custom edge routing.
public List<Point>? Waypoints { get; set; }
Property Value
ZIndex
Gets or sets the Z-index for rendering order. Delegates to State.ZIndex. Default is CanvasElement.ZIndexEdges (200).
public int ZIndex { get; set; }
Property Value
Methods
GetBounds()
Gets the bounding rectangle of this edge. For edges without waypoints, returns an empty rect at origin.
public Rect GetBounds()
Returns
OnPropertyChanged(string?)
Raises the PropertyChanged event.
protected virtual void OnPropertyChanged(string? propertyName)
Parameters
propertyNamestring
Reconnect(string, string)
Reconnects this edge to a different target node and port.
public void Reconnect(string newTarget, string newTargetPort)
Parameters
ReconnectSource(string, string)
Reconnects this edge from a different source node and port.
public void ReconnectSource(string newSource, string newSourcePort)
Parameters
Events
PropertyChanged
Occurs when a property value changes.
public event PropertyChangedEventHandler? PropertyChanged