Layout of links to nodes inside a collapsed group

OK, I have created a new sample application that I think does basically what you seem to be asking for. But I didn’t try to make it pretty.

The Bezier curved links connect up the way I thought they would after the Group (that contains the Node it connects to) is expanded or collapsed.

Window1.xaml:

[code]

<FrameworkElement.Resources>

<go:BooleanStringConverter x:Key=“theButtonConverter” TrueString="-" FalseString="+" />

<DataTemplate x:Key="NodeTemplate">
  <go:NodePanel Sizing="Fixed" go:Part.SelectionAdorned="True">
    <Rectangle Fill="LightBlue" Stroke="Gray" StrokeThickness="2" Width="200" Height="50" />
    <TextBlock Text="{Binding Path=Data.Key}" HorizontalAlignment="Center" VerticalAlignment="Center" />
  </go:NodePanel>
</DataTemplate>

<DataTemplate x:Key="GroupTemplate">
  <Border CornerRadius="5" BorderBrush="DarkBlue" BorderThickness="2" Background="Pink"
          go:Part.SelectionAdorned="True"
          go:Node.LocationElementName="myGroupPanel"
          go:Group.IsSubGraphExpanded="False">
    <StackPanel>
      <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" MinWidth="200">
        <Button x:Name="myCollapseExpandButton" Click="CollapseExpandButton_Click"
            Content="{Binding Path=Group.IsExpandedSubGraph, Converter={StaticResource theButtonConverter}}"
            Width="20" Margin="0 0 5 0" />
        <TextBlock Text="{Binding Path=Data.Key}" FontWeight="Bold" />
      </StackPanel>
      <go:GroupPanel x:Name="myGroupPanel" Padding="5" />
    </StackPanel>
    <go:Group.Layout>
      <go:LayeredDigraphLayout Direction="0" />
    </go:Group.Layout>
  </Border>
</DataTemplate>

<go:DataTemplateDictionary x:Key="LinkTemplateDictionary">
  <DataTemplate x:Key="Main">
    <go:LinkShape Stroke="Black" StrokeThickness="3">
      <go:Link.Route>
        <go:Route Routing="Orthogonal" Corner="10" />
      </go:Link.Route>
    </go:LinkShape>
  </DataTemplate>

  <DataTemplate x:Key="Extra">
    <go:LinkShape Stroke="DarkGray" StrokeThickness="2" go:Part.LayoutId="None">
      <go:Link.Route>
        <go:Route Curve="Bezier"
                  FromSpot="1 0.5" FromEndSegmentLength="50"
                  ToSpot="1 0.5" ToEndSegmentLength="50" />
      </go:Link.Route>
    </go:LinkShape>
  </DataTemplate>
</go:DataTemplateDictionary>

</FrameworkElement.Resources>

[/code] Window1.xaml.cs: [code]/* Copyright © Northwoods Software Corporation, 2008-2011. All Rights Reserved. */

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using Northwoods.GoXam;
using Northwoods.GoXam.Model;

namespace WpfApplication1 {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();

  var nodes = new ObservableCollection<NodeData>() {
    new NodeData() { Key="first", IsSubGraph=false },
    new NodeData() { Key="second", IsSubGraph=true },
    new NodeData() { Key="third", IsSubGraph=true },
    new NodeData() { Key="fourth", IsSubGraph=false },

    new NodeData() { Key="2a", SubGraphKey="second" },
    new NodeData() { Key="2b", SubGraphKey="second" },
    new NodeData() { Key="2c", SubGraphKey="second" },

    new NodeData() { Key="3a", SubGraphKey="third" },
    new NodeData() { Key="3b", SubGraphKey="third" },
  };

  var links = new ObservableCollection<LinkData>() {
    new LinkData() { From="first", To="second", Category="Main" },
    new LinkData() { From="second", To="third", Category="Main" },
    new LinkData() { From="third", To="fourth", Category="Main" },

    new LinkData() { From="2a", To="2b", Category="Main" },
    new LinkData() { From="2a", To="2c", Category="Main" },
    new LinkData() { From="3a", To="3b", Category="Main" },

    new LinkData() { From="2a", To="3a", Category="Extra" },
    new LinkData() { From="2b", To="3b", Category="Extra" },
    new LinkData() { From="2c", To="3b", Category="Extra" },
  };

  var model = new GraphLinksModel<NodeData, String, String, LinkData>();
  model.NodesSource = nodes;
  model.LinksSource = links;
  model.Modifiable = true;
  myDiagram.Model = model;
}

private void Button_Click(object sender, RoutedEventArgs e) {
  myDiagram.LayoutDiagram();
}

private void CollapseExpandButton_Click(object sender, RoutedEventArgs e) {
  // the Button is in the visual tree of a Node
  Button button = (Button)sender;
  Group sg = Part.FindAncestor<Group>(button);
  if (sg != null) {
    NodeData subgraphdata = (NodeData)sg.Data;
    if (!subgraphdata.IsSubGraph) return;
    // always make changes within a transaction
    myDiagram.StartTransaction("CollapseExpand");
    // toggle whether this node is expanded or collapsed
    sg.IsExpandedSubGraph = !sg.IsExpandedSubGraph;
    myDiagram.CommitTransaction("CollapseExpand");
  }
}

}

public class NodeData : GraphLinksModelNodeData { }

public class LinkData : GraphLinksModelLinkData<String, String> { }
}[/code]