Skip to content

Connections Overview

Miroiu Emanuel edited this page Sep 24, 2022 · 7 revisions

Connections are created between two points. The Source and Target dependency properties are of type Point and are usually bound to a connector's Anchor point.

Base connection

The base class for all connections provided by the library is BaseConnection which derives from Shape. There's no restriction to derive from BaseConnection when you create a custom connection.

It exposes two commands with their corresponding events:

  • DisconnectCommand, respectively DisconnectEvent - fired when the connection is clicked while holding ALT
  • SplitCommand, respectively SplitEvent - fired when the connection is double-clicked

The Direction of a connection can have two values:

  • Forward

image image

  • Backward

image image

The SourceOffset and the TargetOffset works together with OffsetMode and will keep distance from the anchor point:

image

Connections also have a Spacing which will make the connection break the angle at a certain distance from the Source and Target points:

  • With spacing:

image

  • Without spacing:

image

Settings the ArrowSize to "0, 0" will remove the arrowhead.

Line connection

A straight line from Source to Target.

image

Circuit connection

Has an Angle dependency property to control where it breaks. Angle is in degrees.

image

Connection

A bezier curve between Source and Target.

image

Pending Connection

A pending connection can be created from a connector and can be dropped on either an ItemContainer (if AllowOnlyConnectors is false) or a Connector.

Content of a pending connection can be customized using the ContentTemplate. If EnablePreview is true, the PreviewTarget will be updated with the connector or item container under the mouse cursor or null if there's no such element.

image

The visibility of pending connections can be controlled using the IsVisible dependency property.

Connection snapping to connectors can be enabled using the EnableSnapping dependency property.

The Source and the Target properties are data contexts of connectors and the Target will be updated when the pending connection is completed.

There's also a StartedCommand which takes the Source as the parameter, respectively a CompletedCommand which takes the Target as the parameter.

Tip: Canceling a pending connection is done by releasing the right mouse button.

Clone this wiki locally