Problem with link

Hi,

I’m facing a weird problem: My diagram usually looks like this:





When i turn the animation off (by using <go:LayoutManager Animated=“False”/>), when the diagram is loaded is looks like this:



If I expand/collapsed a group node, the links go back to their nice curvy look.



Any idea?



Thanks!

That’s odd. It’s as if the nodes hadn’t been initialized yet when the links were routed.

What version of GoWPF are you using?

You could try explicitly re-routing all of the links. Something like:
myDiagram.StartTransaction(“reroute links”);
foreach (Link link in myDiagram.Links) link.Route.InvalidateRoute();
myDiagram.CommitTransaction(“reroute links”);

Caution: I haven’t tried this.

I’ve tried putting this code in the Loaded event, still the same behavior.
I’m using goWpf version 1.2.5.3

With the animation it works normally.

In which Loaded event handler? That might be too early.

Try executing the code in a Diagram.InitialLayoutCompleted event handler.

If you aren’t setting the Diagram.Model when you are loading your diagram, you might need to do it in a Diagram.LayoutCompleted event handler, but presumably you’ll just want to do it once after each load.

Well, just for testing purposes I execited it in the Diagram.LayoutCompleted event handler which executes contantly - but the links are still straight until I expand one of the group nodes…

OK, so my work-around suggestion doesn’t apply at all.

Which nodes are Groups?
The ones with the circular blue arrow buttons?

What do those links on the left actually connect?
For example, the link on the left connecting “First” to “Second” seems to connect the yellow-arrow-#2 port to the green-arrow-#1 port. Is this actually the case, or is the link actually connected to some node inside that group?

Have you set any go:Node.FromSpot or .ToSpot attached property values?

Have you specified a Route.Curviness value?

I found the problem!
in my link template I’m using Bezier curve, while binding the ToEndSegmentLength and FromEndSegmentLength to the actual height using a special converter. The idea is to make long links have bigger curve radius.

The problem is that after the initail loading the link’s actual height is 0…
Still trying to find an elegant way to solve it.

This is my link template:

<go:LinkPanel go:Part.Reshapable="False" go:Part.Movable="False"
						  go:Part.SelectionAdorned="True"
						  go:Part.Selectable="True"
						  go:Part.SelectionElementName="arrowStroke"
						  go:Part.LayoutId="None">
				<go:Link.Route>
					<go:Route Curve="Bezier" Routing="Normal"
							  Smoothness="1"
							  ToShortLength="5" FromShortLength="1"
							  ToEndSegmentLength="{Binding Path=Link.ActualHeight, Converter={StaticResource parameterEndSegmentLengthConverter}}"
							  FromEndSegmentLength="{Binding Path=Link.ActualHeight, Converter={StaticResource parameterEndSegmentLengthConverter}}"
							  ToEndSegmentDirection="RotatedNode"
							  FromEndSegmentDirection="RotatedNode"/>
				</go:Link.Route>
				<Path go:LinkPanel.ToArrow="Standard" go:LinkPanel.ToArrowScale="1"
					  Fill="{Binding Path=Link.IsSelected, Converter={StaticResource theSelectedBrushConverter}}"/>
				<go:LinkShape x:Name="arrowStroke" StrokeThickness="1.5"
							  Stroke="{Binding Path=Link.IsSelected, Converter={StaticResource theSelectedBrushConverter}}"
							  ToolTip="{Binding Path=Data.Text}"/>
			</go:LinkPanel>

Thanks

OK, that’s clever, but a bit problematic, to be depending on the Link.ActualHeight. That’s because changing the …EndSegmentLength causes the link to be re-routed, which might change its ActualHeight. Although in this case it’s probably not going to change in height.

And because during initialization it hasn’t been measured/arranged yet, as you have discovered.

I would probably replace those bindings with some code, executed in a Diagram.LayoutCompleted event handler, that found the distance between the nodes and set the Link.Route.Curviness appropriately.