Request for Link-to-Link Connection Demo and Additional Resources

Ah, sorry about that – the repeated redesigns of our websites have caused such resources to be lost.

Here are the XAML and CS files:

<!-- Copyright © Northwoods Software Corporation, 2008-2024. All Rights Reserved. -->

<UserControl x:Class="LinksToLinks.LinksToLinks"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:go="http://schemas.nwoods.com/GoXam"
    xmlns:local="clr-namespace:LinksToLinks">

  <UserControl.Resources>
    <DataTemplate x:Key="NodeTemplate">
      <go:NodePanel Sizing="Auto" go:Part.SelectionAdorned="True"
                    go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}">
        <go:NodeShape go:NodePanel.Figure="Ellipse"
                      go:Node.PortId="" go:Node.LinkableFrom="True" go:Node.LinkableTo="True"
                      Fill="{Binding Path=Data.Color}" />
        <TextBlock Text="{Binding Path=Data.Key}" Margin="8" />
      </go:NodePanel>
    </DataTemplate>
    
    <go:DataTemplateDictionary x:Key="NodeDTD"
                            Default="{StaticResource NodeTemplate}">
      <DataTemplate x:Key="LinkLabel">
        <Ellipse Fill="Blue" Width="4" Height="4"
               go:Node.LinkableFrom="True" go:Node.LinkableTo="True"
               go:Node.Selectable="False" go:Node.Avoidable="False" />
      </DataTemplate>
    </go:DataTemplateDictionary>
    
    <DataTemplate x:Key="LinkTemplate">
      <go:LinkPanel>
        <go:Link.Route>
          <go:Route RelinkableFrom="True" RelinkableTo="True" />
        </go:Link.Route>
        <go:LinkShape Stroke="Blue" StrokeThickness="2" />
        <Path go:LinkPanel.ToArrow="Standard" Fill="Blue" />
      </go:LinkPanel>
    </DataTemplate>
  </UserControl.Resources>

  <Grid>
    <go:Diagram x:Name="myDiagram" Padding="10"
                HorizontalContentAlignment="Stretch"
                VerticalContentAlignment="Stretch"
                NodeTemplateDictionary="{StaticResource NodeDTD}"
                LinkTemplate="{StaticResource LinkTemplate}">
    </go:Diagram>
  </Grid>
</UserControl>
using System;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using Northwoods.GoXam;
using Northwoods.GoXam.Model;

namespace LinksToLinks {
  public partial class LinksToLinks : UserControl {
    public LinksToLinks() {
      InitializeComponent();

      var model = new GraphLinksModel<MyNodeData, String, String, MyLinkData>();
      model.NodesSource = new ObservableCollection<MyNodeData>() {
        new MyNodeData() { Key="A", Color="LightBlue", Location=new Point(10, 10) },
        new MyNodeData() { Key="B", Color="Pink", Location=new Point(210, 10) },
        new MyNodeData() { Key="A-B", IsLinkLabel=true },
        new MyNodeData() { Key="C", Color="LightGreen", Location=new Point(110, 60) },
      };
      model.LinksSource = new ObservableCollection<MyLinkData>() {
        new MyLinkData() { From="A", To="B", LabelNode="A-B" },
        new MyLinkData() { From="C", To="A-B" },
      };
      model.Modifiable = true;
      myDiagram.Model = model;
      model.HasUndoManager = true;

      // background double-click inserts a new node
      myDiagram.ClickCreatingTool.PrototypeData =
        new MyNodeData() { Color="Yellow" };
      myDiagram.ClickCreatingTool.DoubleClick = true;

      // drawing a new link automatically adds a label node
      myDiagram.LinkDrawn += (s, e) => {
        // create and add a label node data for a newly drawn link data
        var labnode = new MyNodeData() { IsLinkLabel=true };
        myDiagram.Model.AddNode(labnode);
        // then associate it with the link data
        var newlink = e.Part as Link;
        if (newlink != null) {
          var linkdata = newlink.Data as MyLinkData;
          if (linkdata != null) {
            linkdata.LabelNode = labnode.Key;
          }
        }
      };
    }
  }

  public class MyNodeData : GraphLinksModelNodeData<String> {
    public String Color { get; set; }
  }

  public class MyLinkData : GraphLinksModelLinkData<String, String> {
  }
}