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

<UserControl x:Class="NodeFigures.NodeFigures"
    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="NodeFigureTemplate">
      <!-- By setting go:Part.Resizable to true and by naming the shape as the
           go:Part.SelectionElementName, the user can resize the nodes;
           resizing respects the MinWidth/MinHeight/MaxWidth/MaxHeight -->
      <go:NodePanel go:Part.SelectionElementName="Shape" go:Part.SelectionAdorned="True"
                    go:Part.Resizable="True" go:Part.Text="{Binding Path=Data}">
        <!-- The go:NodePanel.Figure attached property specifies the predefined geometry
             to use; you should set the Width and Height as desired. -->
        <go:NodeShape x:Name="Shape" go:NodePanel.Figure="{Binding Path=Data}"
                      Stroke="Black" StrokeThickness="3" Fill="LightGray"
                      Width="100" Height="100" MinWidth="20" MinHeight="20" />
        <!-- The NodePanel places all but the first child element inside the first one. -->
        <TextBlock Text="{Binding Path=Data}" TextAlignment="Center" TextWrapping="Wrap"
                   VerticalAlignment="Center" HorizontalAlignment="Center" />
      </go:NodePanel>
    </DataTemplate>
  </UserControl.Resources>

  <Grid>
    <go:Diagram x:Name="myDiagram" Padding="10"
                NodeTemplate="{StaticResource NodeFigureTemplate}"
                HorizontalContentAlignment="Left" VerticalContentAlignment="Top">
      <go:Diagram.Layout>
        <!-- Position all of the nodes in a grid, using the go:Part.Text binding
             on the go:NodePanel to sort alphabetically -->
        <go:GridLayout Conditions="Standard ViewportSizeChanged" />
      </go:Diagram.Layout>
    </go:Diagram>
  </Grid>
</UserControl>
