Setting a node's from and to spot programmatically

I would like to know how to set a node's fromspot and tospot programmatically(not XAML). I want to set it inside the DoLayout method. I tried the Node.SetToSpot() methode but had no success.
Thank you

If you are calling Node.SetFromSpot or SetToSpot on the FrameworkElement that is the actual port that the links are connected to, that should work.

However, note that each Link has its own Link.Route.FromSpot and ToSpot properties that take precedence over the port’s spots. The link’s route computation only looks at the spot values on the port when the link route’s spots are Spot.Default.

That is the default value for Route.FromSpot and ToSpot, but some of the standard layouts do set those link route properties to make sure everything looks good, just in case the ports have Spot.NoSpot spots. Those predefined layouts have properties such as LayeredDigraphLayout.SetsPortSpots and TreeLayout.SetsPortSpot and SetsChildPortSpot to disable the layout routing setting the spots on the Link Route, if you want to use whatever spot values the nodes/ports have.

So that might be a reason why you are not seeing any changes even if you are setting the spots on the right FrameworkElements.