Adding group panel for child nodes

Hi,
I want to add group to child nodes. I am simply using a Model (I am not using Diagram in code behind) For all the nodes getting created I want to add them in a group. Here’s a sample piece of code I am writing. I have Link and Node templates. Where do I get started from? How do I contain nodes in a group? Where should piece of code written and do I need to code behind?

                    <DataTemplate x:Key="NodeLinks">
                        <go:LinkPanel>
                   <Some Code>
            </go:LinkPanel>
        </DataTemplate>
        <DataTemplate x:Key="ChildNodes">
            <go:NodePanel go:Part.SelectionAdorned="True"
                          go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"
                          Sizing="Auto">
                <StackPanel>
                    <Image Source="{Binding Path=Data.Type, Converter={StaticResource TypeToSymbolConverter}}" />
                    <TextBlock Text="{Binding Path=Data.Title, Converter={StaticResource EmptyToNoNameConverter}}"/>
                </StackPanel>
            </go:NodePanel>
        </DataTemplate>
    <go:Diagram Name="Graph Sample"
                Model="{Binding Model, Mode=TwoWay}"
                LinkTemplate="{StaticResource NodeLinks}"
                NodeTemplate="{StaticResource ChildNodes}">
        <go:Diagram.Layout>
            <go:TreeLayout Angle="90"
        </go:Diagram.Layout>

First, I assume you are using a GraphLinksModel, not a plain DiagramModel.

Second, you need to provide the reference in the node data to the containing group data. That depends on whether you are using your own model data classes or GraphLinksModelNodeData. If you are just starting out, your are probably using the latter, so you just need to set GraphLinksModelNodeData.SubGraphKey on each node data to be the key of the containing group data. That group data needs to have its GraphLinksModelNodeData.IsSubGraph property set to true.

You might want to look at some of the samples that make use of Groups, in GoWpfDemo.

Hi Walter,
Thanks for the reply.
I am using GraphLinksModel.
I am actually confused about providing the reference in the node data because I am using my own model data classes.
Here’s my class;

public class NetworkNode : GraphLinksModelNodeData<string>
{
    private string _title;
    public string Title
    {
        get { return _title; }
        set
        {
            if (_title == value) return;

            var oldValue = _title;
            _title = value;

            RaisePropertyChanged("Title", oldValue, value);
        }
    }
  }

and in the View Model, I am adding those nodes like this;

nodes.Add(new DistributionNetworkNode() { Key = Name, Title = Name });
and to update model

var model = new GraphLinksModel<DistributionNetworkNode, string, string, UniversalLinkData>
        {
            NodeKeyPath = "Key",
            NodesSource = nodes,
            LinksSource = links,
        };
        Model = model;

How do I contain those nodes in a group?

Here is part of the documentation for the GraphLinksModelNodeData class, GoXam for WPF 2.2.4

If you want each node to keep a “reference” to the containing (“parent”) group, you can use the SubGraphKey property. If you want subgraph data to keep a list of “references” to the contained (“children”) nodes, you can use the MemberKeys property. You can use both properties at the same time.

I still stand confused Walter. Where shall I create groups? How do I get group name? Which part of the code needs to be changed exactly. Because I have tried all the possible ways I can think of and its still not coming up. It shows me the group but without group name.

Groups are just nodes with additional properties and behaviors and templates. Read the sections about groups, starting with “Group information in the node data”, in the GoXamIntro.pdf document. And look at the samples that use groups.