Here’s the Group template:
Here’s the Node template:
<StackPanel Orientation="Horizontal"
go:Part.LayerName="{Binding Path=Data.LayerName}"
go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"
go:Node.LocationSpot="Center"
go:Part.SelectionAdorned="true"
go:Part.SelectionElementName="Container">
<go:SpotPanel
go:Part.Rotatable="False"
go:Part.Resizable="False"
go:Node.LinkableFrom="true"
go:Node.LinkableTo="true"
go:Node.LinkableSelfNode="False"
go:Node.LinkableDuplicates="False"
go:Node.PortId="">
<go:NodePanel Sizing="Auto" Cursor="Hand">
<Border x:Name="Container" Style="{StaticResource MeasureNodeOuterBorderStyle}" go:NodePanel.Spot1="0 0" go:NodePanel.Spot2="1 1" go:Node.PortId="">
<Border Style="{StaticResource MeasureNodeInnerBorderStyle}" go:Node.LinkableFrom="false" go:Node.LinkableTo="false">
<Grid>
<TextBlock Text="{Binding Data.Text}" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" />
<TextBlock Text="{Binding Data.Key}" VerticalAlignment="Bottom" HorizontalAlignment="Center" TextWrapping="Wrap" />
<Button
Content="{Binding Node.IsExpandedTree, Converter={StaticResource NodeExpandButtonConverter}}"
Command="{Binding CollapseExpandNodeTreeCommand, Source={StaticResource NodeCommandManager}}"
CommandParameter="{Binding Node}"
Visibility="{Binding Data.HasOutboundNodes, Converter={StaticResource VisibilityBooleanConverter}}"
VerticalAlignment="Bottom" HorizontalAlignment="Right" Height="14" Width="14" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="0,0,2,2" Padding="0" />
</Grid>
</Border>
</Border>
<telerik:RadContextMenu.ContextMenu>
<!-- TODO
Remove the context menu. For demo only
-->
<telerik:RadContextMenu>
<telerik:RadMenuItem Header="Edit Measure" />
<telerik:RadMenuItem Header="Remove Measure" />
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
</go:NodePanel>
<Rectangle Fill="Transparent" Width="6" Height="6"
go:SpotPanel.Spot="MiddleLeft" go:SpotPanel.Alignment="MiddleLeft"
go:Node.PortId="L" go:Node.LinkableFrom="True" go:Node.LinkableTo="True" Cursor="Hand"
go:Node.FromSpot="MiddleLeft" go:Node.ToSpot="MiddleLeft" go:Node.LinkableDuplicates="False" />
<Rectangle Fill="Transparent" Width="6" Height="6"
go:SpotPanel.Spot="MiddleTop" go:SpotPanel.Alignment="MiddleTop"
go:Node.PortId="T" go:Node.LinkableFrom="True" go:Node.LinkableTo="True" Cursor="Hand"
go:Node.FromSpot="MiddleTop" go:Node.ToSpot="MiddleTop" go:Node.LinkableDuplicates="False" />
<Rectangle Fill="Transparent" Width="6" Height="6"
go:SpotPanel.Spot="MiddleRight" go:SpotPanel.Alignment="MiddleRight"
go:Node.PortId="R" go:Node.LinkableFrom="True" go:Node.LinkableTo="True" Cursor="Hand"
go:Node.FromSpot="MiddleRight" go:Node.ToSpot="MiddleRight" go:Node.LinkableDuplicates="False" />
<Rectangle Fill="Transparent" Width="6" Height="6"
go:SpotPanel.Spot="MiddleBottom" go:SpotPanel.Alignment="MiddleBottom"
go:Node.PortId="B" go:Node.LinkableFrom="True" go:Node.LinkableTo="True" Cursor="Hand"
go:Node.FromSpot="MiddleBottom" go:Node.ToSpot="MiddleBottom" go:Node.LinkableDuplicates="False" />
</go:SpotPanel>
</StackPanel>
</DataTemplate>
Here’s the code I’m using to build the diagram:
<span =“Apple-tab-span” style=“white-space:pre”>
diagram.Model.StartTransaction(“Test”);
var group = new BaseGraphLinksModelNodeData<string>();
group.IsSubGraph = true;
group.Key = "TheGroup";
group.Text = "Grouper";
diagram.Model.AddNode(group);
var n1 = new BaseGraphLinksModelNodeData<string> { Key = "32", Location = new Point(250, 80), Text = "Accounts Payable", SubGraphKey="TheGroup"};
var n2 = new BaseGraphLinksModelNodeData<string> { Key = "10", Location = new Point(160, 210), Text = "Administration Expenses", SubGraphKey = "TheGroup" };
var n3 = new BaseGraphLinksModelNodeData<string> { Key = "22", Location = new Point(330, 210), Text = "Cash", SubGraphKey = "TheGroup" };
var n4 = new BaseGraphLinksModelNodeData<string> { Key = "16", Location = new Point(183, 329), Text = "Deprecitation", SubGraphKey = "TheGroup" };
diagram.Model.AddNode(n1);
diagram.Model.AddNode(n2);
diagram.Model.AddNode(n3);
diagram.Model.AddNode(n4);
diagram.Model.AddLink(n1, null, n2, "T");
diagram.Model.AddLink(n1, null, n3, "T");
diagram.Model.AddLink(n2, null, n4, "T");
diagram.Model.CommitTransaction("Test");