In my project I have various templates for the links. But when I use a custom template for the open connection the open end of the connection always moves to left top corner. However for the default link it works fine.
I tried to replicate the same in demo and in Piping example I faced the similar problem,
Below are the changes made:
Subscribed to this event:
myDiagram.Model.Changed += ModelOnChanged;
private void ModelOnChanged(object sender, ModelChangedEventArgs e)
{
if (e.Change.Equals(ModelChange.CommittedTransaction) && e?.OldValue != null)
{
var edits = (e?.OldValue as UndoManager.CompoundEdit).Edits.Select(edit => edit as ModelChangedEventArgs)
.ToList();
foreach (ModelChangedEventArgs lastOperation in edits)
{
switch (lastOperation?.Change)
{
case ModelChange.AddedLink:
PipeData data = lastOperation.Data as PipeData;
Link link = myDiagram.PartManager.FindLinkForData(data, myDiagram.Model);
link.Route.RecomputePoints();
data.Category = "MyPipeTemplate";
break;
}
}
}
}
and I added the link template as below:
<go:DataTemplateDictionary x:Key="LinkTemplateDictionary">
<DataTemplate x:Key="PipeTemplate">
<go:LinkPanel go:Part.Reshapable="True"
go:Part.DropOntoBehavior="SplicesIntoLink">
<go:Link.Route>
<go:Route Routing="AvoidsNodes" Curve="JumpOver" Corner="5"
FromEndSegmentDirection="RotatedNodeOrthogonal"
ToEndSegmentDirection="RotatedNodeOrthogonal"
RelinkableFrom="True" RelinkableTo="True"
ToShortLength="5" />
</go:Link.Route>
<!-- in order to simulate a gradient across the breadth of the pipe, regardless of the pipe's direction,
use multiple superimposed link shapes, each narrower and lighter than the previous one -->
<go:LinkShape
Stroke="{Binding Path=Link.IsDropOntoAccepted, Converter={StaticResource theStrokeChooser}}"
StrokeThickness="5" />
<go:LinkShape Stroke="Gray" StrokeThickness="3" />
<go:LinkShape Stroke="WhiteSmoke" StrokeThickness="1" />
<Path go:LinkPanel.ToArrow="Triangle" Fill="Black" />
</go:LinkPanel>
</DataTemplate>
<DataTemplate x:Key="MyPipeTemplate">
<go:LinkPanel go:Part.Reshapable="True"
go:Part.DropOntoBehavior="SplicesIntoLink">
<go:Link.Route>
<go:Route Routing="AvoidsNodes" Curve="JumpOver" Corner="5"
FromEndSegmentDirection="RotatedNodeOrthogonal"
ToEndSegmentDirection="RotatedNodeOrthogonal"
RelinkableFrom="True" RelinkableTo="True"
ToShortLength="5" />
</go:Link.Route>
<!-- in order to simulate a gradient across the breadth of the pipe, regardless of the pipe's direction,
use multiple superimposed link shapes, each narrower and lighter than the previous one -->
<go:LinkShape
Stroke="{Binding Path=Link.IsDropOntoAccepted, Converter={StaticResource theStrokeChooser}}"
StrokeThickness="5" />
<go:LinkShape Stroke="Brown" StrokeThickness="3" />
<go:LinkShape Stroke="Blue" StrokeThickness="1" />
<Path go:LinkPanel.ToArrow="Triangle" Fill="Black" />
</go:LinkPanel>
</DataTemplate>
</go:DataTemplateDictionary>
After these changes I could see the open connection is moving to the top left corner instead of staying at the place I dropped.