Cannot position nodes on a link

I have problems positioning nodes on a link.

I have used your Piping samle as origin for my work. I am able to assign a node to a link, but when I drag the node along the link it finds another position after the drag operation (see figures)

This is where I want to place the node

This is where the node ends up

XAML Code for the Pipe Template:

XAML for the Node Template

Code-behind

protected override void DropOnto(System.Windows.Point pt)
{
Model model = (Model)this.Diagram.Model;

        Part part = this.Diagram.SelectedPart;

        if (part.Data.GetType() == typeof(AnodeData))
        {
            Link link = null;
            
            if (part.ContainingSubGraph != null)
            {
                link = part.ContainingSubGraph.LabeledLink;

                if (link != null)
                {
                    Point partPoint = new Point(part.Bounds.X + part.Bounds.Width / 2, part.Bounds.Y + part.Bounds.Y / 2);
                    
                    var pts = link.Route.Points;

                    if (pts.Count >= 2)
                    {
                        int index = link.Route.FindClosestSegment(partPoint);
                        if (index >= pts.Count - 1) index = pts.Count - 2;

                        Point a = pts[index];
                        Point b = pts[index + 1];

                        switch (((ItemData)part.Data).ItemDataType)
                        {
                            case ItemDataType.Anode:
                                AnodeData anode = (AnodeData)part.Data;
                                anode.SegmentIndex = index;
                                if (Math.Abs(a.Y - b.Y) < 0.1)
                                {
                                    if (a.X < b.X)
                                    {
                                        anode.Fraction = (partPoint.X <= a.X ? 0 : (partPoint.X >= b.X ? 1 : (partPoint.X - a.X) / (b.X - a.X)));
                                        anode.Location = new Point(0, partPoint.Y - a.Y);
                                    }
                                    else
                                    {
                                        anode.Fraction = (partPoint.X >= a.X ? 0 : (partPoint.X <= b.X ? 1 : (partPoint.X - a.X) / (b.X - a.X)));
                                        anode.Location = new Point(0, a.Y - partPoint.Y);
                                    }
                                }
                                else
                                {
                                    if (a.Y < b.Y)
                                    {
                                        anode.Fraction = (partPoint.Y <= a.Y ? 0 : (partPoint.Y >= b.Y ? 1 : (partPoint.Y - a.Y) / (b.Y - a.Y)));
                                        anode.Location = new Point(0, a.X - partPoint.X);
                                    }
                                    else
                                    {
                                        anode.Fraction = (partPoint.Y >= a.Y ? 0 : (partPoint.Y <= b.Y ? 1 : (partPoint.Y - a.Y) / (b.Y - a.Y)));
                                        anode.Location = new Point(0, partPoint.X - a.X);
                                    }
                                }
                                break;
                        }
                    }
                }
            }

            this.AnodeDropOnto((AnodeData)part.Data, link, pt);                              
            return;
        }

        if (part.Data.GetType() == typeof(PipeNodeData))
        {
            INode node = model.ProjectVersion.GetNode(((PipeNodeData)part.Data).Index.ToString());
            node.X = pt.X;
            node.Y = pt.Y;
            return;
        }

        if (part.Data.GetType() == typeof(SinkData))
        {
            ISink sink = model.ProjectVersion.GetSink(((SinkData)part.Data).Index.ToString());
            sink.X = pt.X;
            sink.Y = pt.Y;
            return;
        }                        
    }

I think the Binding on go:LinkPanel.Offset ought to be to the “Location” property, not the “Offset” property. Are you getting warnings in the Output window when debugging?

I have tried your suggestion but it did not help me.

I am a little bit confused with the properties of the go:LinkPanel.

Why is it necessary to use the Offset property when you have the Fraction property?

The LinkPanel.Index attached property specifies which segment that the label will be on.
The LinkPanel.Fraction attached property specifies how far along the segment the label will be.
Together the Index and Fraction determine a point at (or near) which the label will be.

The LinkPanel.Offset attached property specifies an additional offset from that point. The actual offset is determined by rotating the offset point about the point determined by the Index and Fraction by the angle that that segment takes. So when the segment has an angle of zero, the LinkPanel.Offset and the computed offset will be the same.