Is there way to initiate the start of a connection without the user clicking on a port?

I am attempting to implement an “auto-connect” feature where the user can drag a node close to one that is already on the graph. If the user gets close enough to an existing node, while it is dragging it should also start a connection. Ideally, this would work exactly like when you click on an output port (obviously without the clicking) and not snap to the ports of other existing nodes on the graph. Once the user drops the item and node is created and the connection can be made. I can make the connection after the fact, but how can I get a connection to start and follow the mouse, with snapping to other ports on the graph?

First, the answer to your literal question is given by the documentation of the LinkingTool class:

If you want to programmatically start a new user mouse-gesture to draw a new link from a given FrameworkElement that may be a “port” element or may be within the visual tree of a “port” element, set the StartElement property to let FindLinkablePort find the real “port” element. Then start and activate this tool:

               myDiagram.LinkingTool.StartElement = ...;
               myDiagram.CurrentTool = myDiagram.LinkingTool;
               myDiagram.CurrentTool.DoActivate();

But from your description I don’t think this is what you want, because you are assuming that the user is dragging a node and not drawing a new link, and one cannot do both at the same time.

A better answer:

I think what you’ll need to do is override the DraggingTool. During the drag you’d need to identify nearby compatible ports and create temporary links from the dragged node to those stationary ports.

Caution: you should also deal with multiple nodes being dragged simultaneously and with multiple ports on those nodes potentially connecting to multiple stationary ports at the same time. Perhaps you’ll deal by simplifying things and disallowing multiple dragged nodes and/or multiple links to multiple ports.

We do have an unpublished sample that does something similar but different from what you describe. The Pipes sample, Similar to GoJS Pipes Example in GoXam (GoXam) and Pipes (GoJS), allows the user to drag a node which snaps the node’s position so that one of its ports are coincident with a compatible port of a stationary node. Try the GoJS sample to see what I mean.

The reason I suggest the Pipes sample is that it has a custom DraggingTool that does most of what I describe. But in your case, rather than snapping the node’s position to an existing node, you would create one or more temporary links to them. As the user drags the node farther away you would remove the temporary links. And upon a successful (i.e. not canceled) drop, you would remove all temporary links and then create real links in the model.