Diagramm always moves to the top left node

Hi,
how can I prevent the Diagram from moving to the top/left node if I move the nodes?

<go:Diagram NodesSource="{Binding PilotObjectList}" NodeTemplateDictionary="{StaticResource NodeTemplates}" InitialScale="1.0" InitialStretch="Uniform" />

I’m sorry, could you explain the situation in a bit more detail? Are you talking about the user dragging some nodes, and then they are automatically moved towards the top and left by some distance?

Also, your InitialScale and InitialStretch properties are in conflict with each other, since the former says that the DiagramPanel.Scale should be 1.0 whereas the latter says that it should be whatever is needed to show the whole diagram contents (the DiagramPanel.DiagramBounds) within the viewport.

You have a diagram and two nodes:

±------------------------------+

|Node1 |
| |
| |
| Node2 |
| |
| |
| |
+-------------------------------+
now you move Node1 to the right of Node2 with the mouse:
+-------------------------------+
| |
| |
| |
| Node2 Node1 |
| |
| |
| |
+-------------------------------+
now the Diagram moves itself to the following situation:
+-------------------------------+
|Node2 Node1 |
| |
| |
| |
| |
| |
| |
+-------------------------------+

Try something like this:

   <go:Diagram x:Name="myDiagram">
      <Control.Template>
        <ControlTemplate TargetType="go:Diagram">
          <Border x:Name="Border"
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}">
            <ScrollViewer HorizontalScrollBarVisibility="Auto"
                    VerticalScrollBarVisibility="Auto"
                    CanContentScroll="True">
              <local:CustomDiagramPanel x:Name="Panel"
                         Stretch="{TemplateBinding Stretch}"
                         Padding="{TemplateBinding Padding}"
                         HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                         VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
            </ScrollViewer>
          </Border>
        </ControlTemplate>
      </Control.Template>
  </go:Diagram>

public class CustomDiagramPanel : DiagramPanel {
  protected override Rect ComputeDiagramBounds() {
    var r = base.ComputeDiagramBounds();
    // always include the current viewport position
    var loc = this.ViewportBounds.Location;
    loc.X += this.Padding.Left;
    loc.Y += this.Padding.Top;
    r.Union(loc);
    return r;
  }
}

I’m not sure this addresses your issue or not. Please try it with all kinds of situations to see if it improves the experience for you.

Yes,
this fixed my problem.

Thank you very much.

I tried to set VerticalContentAlignment=“Stretch” HorizontalContentAlignment=“Stretch” this seems to be working, but it doesn’t.