If you manually or programmatically change the position of either node, does the link route itself correctly?
When you change the bound data in the model, do you do so within a model transaction? I’m guessing that’s not happening, so the link doesn’t get a chance to re-route.
I've inherited this problem from Mike. You were right, we weren't using transactions, so I tried wrapping the change to curved links in starttransaction/committransaction, but it had no affect.
When you manually move the "to" node, the arrowhead stays detached. The amount of offset changes as you move it around though.
How big is the “test unit” node? Is it much wider than the visible icon and “test unit” TextBlock?
The other oddity is that the arrowhead is not aligned correctly with the end of the link shape. Normally if you just set the attached ToArrow property, everything just works:
<DataTemplate x:Key="LinkTemplate">
<go:LinkPanel go:Part.SelectionElementName="Path" go:Part.SelectionAdorned="True">
<!-- the link's Route is drawn as a Bezier curve -->
<go:Link.Route>
<go:Route Curve="Bezier" />
</go:Link.Route>
<!-- a simple thin black line -->
<go:LinkShape x:Name="Path" Stroke="Black" StrokeThickness="1" />
<!-- a standard arrowhead -->
<Path Fill="Black" go:LinkPanel.ToArrow="Standard" />
</go:LinkPanel>
</DataTemplate>
This is taken from the Beat Paths sample.
We weren’t setting the ToArrow property. So I added it to our template(see below). Unfortunately, that did not fix it. The test unit node is bigger than the icon. It is 20x20.
LinkPanel has several attached properties that, like other panel attached properties, should be set on the immediate child elements of the panel. That’s not the case here. Furthermore the LinkShape must be an immediate child of the LinkPanel, not inside a Grid. So you need to remove the Grid and move the context menu – I suggest to the LinkPanel.
The NodePanel inside the link template seems superfluous. Just set those LinkPanel attached properties directly on the ContentControl.
Regarding the node DataTemplate, it doesn’t make sense for the main object of the NodePanel to be a Grid containing a context menu. I suspect the main object used to be either the Image or the EntityControl. Remove the Grid and move the context menu elsewhere, such as on the whole NodePanel.
Part or Node or Link attached properties go on the root element of the DataTemplate. (There are some exceptions, such as port-related attached properties.) So the go:Part.Movable=“True” should not be there. It’s unnecessary anyway, because that’s the default value.
And the two port-related properties, go:Node.LinkableFrom and LinkableTo are useless there because you haven’t declared that element to be a port by setting go:Node.PortId to a string. (Well, maybe you do so programmatically, but that’s unlikely.)
Anyway, I’m guessing that the problem is that links are connecting to the edge of your nodes, but it doesn’t look that way because the EntityControl is not visible for some reason and that it’s a lot bigger than the Image.