Overriding SpliceIntoLink Behaviour

I have added anchors for linking on one node, and when I link to the anchor the link stays with the node, but if I connect the link to the whole node then the link doesn’t move with the node.

Here is the node template with the link anchors added:


<DataTemplate x:Key="Compressor">
        <go:SpotPanel             
            go:Part.SelectionAdorned="True"
            go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"
            go:Node.LocationSpot="Center"
            go:Part.Resizable="False"
            go:Part.ResizeElementName="Container"
            go:Part.Reshapable="False"
            Height="{Binding ElementName=Container, Path=Height }" 
            Width="{Binding ElementName=Container, Path=Width}">
            <Grid Name="Container" 
                  Height="{Binding Path=Data.Height, Mode=TwoWay}"
                  Width="{Binding Path=Data.Width, Mode=TwoWay}">
                <FrameworkElement.ToolTip>
                    <TextBlock Text="{Binding Path=Data.Text}" />
                </FrameworkElement.ToolTip>
                <Viewbox Stretch="Fill">
                    <Grid Background="White"
                          go:Node.PortId="" go:Node.LinkableFrom="True" go:Node.LinkableTo="True" Cursor="Hand"
                          go:Node.FromSpot="AllSides" go:Node.ToSpot="AllSides">                    
                        <Path StrokeThickness="1.5" Stroke="#ff000000" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeLineJoin="Round"              
                              Data="..."/>                    
                    </Grid>
                </Viewbox>
                <Rectangle Fill="Transparent" Margin="10" />                            
            
            </Grid>

            <Rectangle Fill="Transparent" Width="6" Height="6"
                           Stroke="{Binding Path=Node.Tag, Converter={StaticResource theStrokeChooser}}"
                           go:SpotPanel.Spot="MiddleLeft" go:SpotPanel.Alignment="MiddleLeft"
                           go:Node.PortId="L" go:Node.LinkableFrom="True" go:Node.LinkableTo="True" Cursor="Hand"                           
                           go:Node.FromSpot="MiddleLeft" go:Node.ToSpot="MiddleLeft" />
            <Rectangle Fill="Transparent" Width="6" Height="6"
                           Stroke="{Binding Path=Node.Tag, Converter={StaticResource theStrokeChooser}}"
                           go:SpotPanel.Spot="MiddleTop" go:SpotPanel.Alignment="MiddleTop"
                           go:Node.PortId="T" go:Node.LinkableFrom="True" go:Node.LinkableTo="True" Cursor="Hand"
                           go:Node.FromSpot="MiddleTop" go:Node.ToSpot="MiddleTop" />
            <Rectangle Fill="Transparent" Width="6" Height="6"
                           Stroke="{Binding Path=Node.Tag, Converter={StaticResource theStrokeChooser}}"
                           go:SpotPanel.Spot="MiddleRight" go:SpotPanel.Alignment="MiddleRight"
                           go:Node.PortId="R" go:Node.LinkableFrom="True" go:Node.LinkableTo="True" Cursor="Hand"
                           go:Node.FromSpot="MiddleRight" go:Node.ToSpot="MiddleRight" />
            <Rectangle Fill="Transparent" Width="6" Height="6"
                           Stroke="{Binding Path=Node.Tag, Converter={StaticResource theStrokeChooser}}"
                           go:SpotPanel.Spot="MiddleBottom" go:SpotPanel.Alignment="MiddleBottom"
                           go:Node.PortId="B" go:Node.LinkableFrom="True" go:Node.LinkableTo="True" Cursor="Hand"
                           go:Node.FromSpot="MiddleBottom" go:Node.ToSpot="MiddleBottom" />
        </go:SpotPanel>
    </DataTemplate>

Any idea what might cause the difference? Also, for whatever reason when linking to/from the whole node the pink linking box that pops up is much larger than the actual node… Any thoughts on what might cause that?

That’s very odd.

Do you need that binding of SpotPanel.Width to ElementName=Container?
That looks suspicious, because the SpotPanel might want to be bigger than the first element (the Grid).
I think you shouldn’t specify the Width or Height at all.

The binding has been removed… It was there because I was checking if the root element was causing the pink linking box to be larger than the actual node, but everything behaves the same with/without it.

Ah, that’s probably because the other elements weren’t placed (partly or fully) outside of the Grid, so the Width and Height would be the same.
Still, the bindings would have caused a problem in the general case, if not this particular case.

If you remove the Viewbox, do the links connect correctly? The Path shape might be too small or might be clipped, but ignore that problem for now…

This does work in general, as you see in the Draggable Link sample.
So I’m just trying to find differences from that sample.

Removing the ViewBox fixes the links staying connected and fixes the size of the linking box, but does clip the shape.

OK, try moving the go:Node.PortId="" and the other Node attached properties from the Path to the Grid. And restore the Viewbox, of course.

All of the Node attached properties are already on the Grid, do you mean to move them from the Grid to the Path? If so, I should note some of our other objects have multiple paths, so I’m not sure how that would work or if it would even matter.

Just the port-related properties, not the node properties on the root element.

That seems to have done the trick, thank you for all of your help.

Ryan