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

<UserControl x:Class="DoubleTree.DoubleTree"
    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">

  <UserControl.Resources>
    <DataTemplate x:Key="NodeTemplate">
      <!-- the text and the background color come from the node data -->
      <!-- the Part.LayoutId attached property controls which TreeLayout lays out the node -->
      <Border Background="{Binding Path=Data.Color}"
              BorderBrush="Black" BorderThickness="1" Padding="5" CornerRadius="5"
              go:Part.LayoutId="{Binding Path=Data.LayoutId}">
        <TextBlock Text="{Binding Path=Data.Text}" HorizontalAlignment="Center" />
      </Border>
    </DataTemplate>

    <DataTemplate x:Key="LinkTemplate">
      <!-- a fairly standard "arrow-like" link template with no selection handle -->
      <go:LinkPanel>
        <go:LinkShape Stroke="Black" StrokeThickness="1" />
        <Path Stroke="Black" go:LinkPanel.ToArrow="OpenTriangle" />
      </go:LinkPanel>
    </DataTemplate>
  </UserControl.Resources>

  <Grid>
    <go:Diagram x:Name="myDiagram" Padding="10"
                HorizontalContentAlignment="Center"
                VerticalContentAlignment="Center"
                NodeTemplate="{StaticResource NodeTemplate}"
                LinkTemplate="{StaticResource LinkTemplate}">
      <go:Diagram.Layout>
        <!-- the diagram's layout is actually by four separate tree layouts,
             one for each direction -->
        <!-- the "FixedRoots" arrangement causes the ROOT node not to be moved -->
        <!-- not setting the port spot at each parent node means links will
             come out straight from the center -->
        <go:MultiLayout>
          <go:TreeLayout Id="Right" Angle="0" Arrangement="FixedRoots" SetsPortSpot="False" />
          <go:TreeLayout Id="Down" Angle="90" Arrangement="FixedRoots" SetsPortSpot="False" />
          <go:TreeLayout Id="Left" Angle="180" Arrangement="FixedRoots" SetsPortSpot="False" />
          <go:TreeLayout Id="Up" Angle="270" Arrangement="FixedRoots" SetsPortSpot="False" />
        </go:MultiLayout>
      </go:Diagram.Layout>
    </go:Diagram>
  </Grid>
</UserControl>
