Drag node into Group

Hi !
I readed about groups, and saw FlowChart and Planogram example, but I am with one problem:
I don´t know what is missing, because when I dragged node into group, it doesn´t stay into, I can move Group, without this new dragged node…, why ? See my code, please… I mixed FlowChart and Planogram examples:

DESIGN:

<UserControl.Resources>

    <!--This converter produces the stroke brush for ports ( ports are points to connect )-->
    <go:BooleanBrushConverter x:Key="theBooleanBrushConverter" TrueBrush="Black" FalseBrush="Transparent" />
    <!--Link labels are visible when they come from a "Conditional" node-->
    <local:LabelVisibilityConverter x:Key="theLabelVisibilityConverter" />
    <!--The DataTemplateDictionary used to store all the DataTemplates for the Node categories. -->
    <go:DataTemplateDictionary x:Key="NodeTemplateDictionary" />



    <!-- A class containing all the slider, checkbox and combobox information to directly bind to. -->
    <local:FlowOptions x:Key="FlowOptions" />

    <!--The brushes for Start and End nodes -->
    <RadialGradientBrush x:Key="theNodeBrush" GradientOrigin="-0.2,-0.2">
        <GradientStop Color="White" Offset="0.35" />
        <GradientStop Color="#FF9FE800" Offset="1" />
    </RadialGradientBrush>



    <!--Note: Binding in styles does not work in Silverlight,
     so all such bindings have been moved to the target element. -->

    <!--Because SpotPanel is used as the root of each node template,
     in order to hold all of the (sometimes visible) ports,
     this style applies to all nodes -->
    <Style TargetType="go:SpotPanel" x:Key="SpotPanelStyle">
        <Setter Property="go:Node.SelectionElementName" Value="Shape" />
        <Setter Property="go:Node.SelectionAdorned" Value="True" />
        <Setter Property="go:Node.LocationSpot" Value="Center" />
    </Style>

    <!--For the primary shape of each node -->
    <Style TargetType="go:NodeShape" x:Key="NodeShapeStyle">
        <Setter Property="Stroke" Value="Black" />
        <Setter Property="StrokeThickness" Value="1" />
    </Style>

    <!--For the text of each node -->
    <Style TargetType="TextBlock" x:Key="TextBlockStyle">
        <Setter Property="TextWrapping" Value="Wrap" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="HorizontalAlignment" Value="Center" />
        <Setter Property="Margin" Value="5" />
        <Setter Property="go:Part.TextEditable" Value="True" />
    </Style>

    <!--This style is used for all ellipses, which act as ports  -->
    <Style TargetType="Ellipse" x:Key="EllipseStyle">
        <Setter Property="Width" Value="7" />
        <Setter Property="Height" Value="7" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Fill" Value="Transparent" />
        <Setter Property="go:Node.LinkableFrom" Value="True" />
        <Setter Property="go:Node.LinkableTo" Value="True" />
    </Style>

    <!-- A custom adornment template that makes the border Black in Label template-->
    <DataTemplate x:Key="BoxNodeAdornmentTemplate">
        <go:SelectionHandle Stroke="LightGray" StrokeThickness="1" go:Part.Selectable="False" />
    </DataTemplate>

    <!-- Our converters; necessary for successful databinding-->
    <go:BooleanBrushConverter x:Key="theStrokeChooser" TrueBrush="Green" FalseBrush="Black" />
    

    <!-- A custom resize handle template that makes handles red-->
    <DataTemplate x:Key="GroupResizeAdornmentTemplate">
        <go:SpotPanel>
            <go:ToolHandle go:SpotPanel.Spot="0.0 0.0" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="Black" Stroke="Black" StrokeThickness="1" />
            <go:ToolHandle go:SpotPanel.Spot="0.5 0.0" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="Black" Stroke="Black" StrokeThickness="1" />
            <go:ToolHandle go:SpotPanel.Spot="1.0 0.0" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="Black" Stroke="Black" StrokeThickness="1" />

            <go:ToolHandle go:SpotPanel.Spot="0.0 0.5" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="Black" Stroke="Black" StrokeThickness="1" />
            <go:ToolHandle go:SpotPanel.Spot="1.0 0.5" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="Black" Stroke="Black" StrokeThickness="1" />

            <go:ToolHandle go:SpotPanel.Spot="0.0 1.0" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="Black" Stroke="Black" StrokeThickness="1" />
            <go:ToolHandle go:SpotPanel.Spot="0.5 1.0" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="Black" Stroke="Black" StrokeThickness="1" />
            <go:ToolHandle go:SpotPanel.Spot="1.0 1.0" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="Black" Stroke="Black" StrokeThickness="1" />
        </go:SpotPanel>
    </DataTemplate>
    
    


    <!-- There is a separate DataTemplate for each Node category. This allows for large differences between categories.-->
    <DataTemplate x:Key="Comment">
        <go:SpotPanel Style="{StaticResource SpotPanelStyle}" go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"  go:Part.SelectionAdornmentTemplate="{StaticResource BoxNodeAdornmentTemplate}">
            <go:NodePanel Sizing="Auto" go:SpotPanel.Main="True">
                <go:NodeShape x:Name="Shape" Style="{StaticResource NodeShapeStyle}"  Fill="{StaticResource theNodeBrush}"  go:NodePanel.Figure="{Binding Path=Data.Figure}" />
                <TextBlock  Style="{StaticResource TextBlockStyle}" Text="{Binding Path=Data.Text, Mode=TwoWay}" TextAlignment="Center" />
            </go:NodePanel>
        </go:SpotPanel>
    </DataTemplate>



    <DataTemplate x:Key="Start">
        <go:SpotPanel Style="{StaticResource SpotPanelStyle}" go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"  go:Part.SelectionAdornmentTemplate="{StaticResource BoxNodeAdornmentTemplate}" MouseEnter="Node_MouseEnter" MouseLeave="Node_MouseLeave">
            <go:NodePanel Sizing="Auto" go:SpotPanel.Main="True">
                <go:NodeShape x:Name="Shape" Style="{StaticResource NodeShapeStyle}" go:NodePanel.Figure="{Binding Path=Data.Figure}" Fill="{StaticResource theNodeBrush}" />
                <TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding Path=Data.Text, Mode=TwoWay}" TextAlignment="Center" />
            </go:NodePanel>
            <!-- A Start node has only three ports, all outgoing only.
           Port appearance depends on the Node.Tag property.
           The FromSpot and ToSpot properties control where the link connects.
           The SpotPanel properties control where the port is positioned. -->
            <Ellipse Style="{StaticResource EllipseStyle}"
             Stroke="{Binding Path=Node.Tag,
                      Converter={StaticResource theBooleanBrushConverter}}"
             go:Node.PortId="0"
             go:Node.LinkableTo="False"
             go:Node.FromSpot="MiddleBottom"
             go:SpotPanel.Spot="MiddleBottom"
             go:SpotPanel.Alignment="MiddleBottom" />
            <Ellipse Style="{StaticResource EllipseStyle}"
             Stroke="{Binding Path=Node.Tag,
                      Converter={StaticResource theBooleanBrushConverter}}"
             go:Node.PortId="2"
             go:Node.LinkableTo="False"
             go:Node.FromSpot="MiddleLeft"
             go:SpotPanel.Spot="MiddleLeft"
             go:SpotPanel.Alignment="MiddleLeft" />
            <Ellipse Style="{StaticResource EllipseStyle}"
             Stroke="{Binding Path=Node.Tag,
                      Converter={StaticResource theBooleanBrushConverter}}"
             go:Node.PortId="3"
             go:Node.LinkableTo="False"
             go:Node.FromSpot="MiddleRight"
             go:SpotPanel.Spot="MiddleRight"
             go:SpotPanel.Alignment="MiddleRight" />
        </go:SpotPanel>
    </DataTemplate>



    <DataTemplate x:Key="Standard">
        <go:SpotPanel Style="{StaticResource SpotPanelStyle}" go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"  go:Part.SelectionAdornmentTemplate="{StaticResource BoxNodeAdornmentTemplate}" MouseEnter="Node_MouseEnter" MouseLeave="Node_MouseLeave">
            <go:NodePanel Sizing="Auto" go:SpotPanel.Main="True">
                <go:NodeShape x:Name="Shape" Style="{StaticResource NodeShapeStyle}" Fill="{StaticResource theNodeBrush}" go:NodePanel.Figure="{Binding Path=Data.Figure}" />
                <TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding Path=Data.Text, Mode=TwoWay}"  TextAlignment="Center"/>
            </go:NodePanel>
            <!-- A Standard node has four ports, the top incoming only, the
           bottom outgoing only, and the other two support both directions.
           Port appearance depends on the Node.Tag property.
           The FromSpot and ToSpot properties control where the link connects.
           The SpotPanel properties control where the port is positioned. -->
            <Ellipse Style="{StaticResource EllipseStyle}"
             Stroke="{Binding Path=Node.Tag,
                      Converter={StaticResource theBooleanBrushConverter}}"
             go:Node.PortId="0"
             go:Node.LinkableTo="False"
             go:Node.FromSpot="MiddleBottom"
             go:SpotPanel.Spot="MiddleBottom"
             go:SpotPanel.Alignment="MiddleBottom" />
            <Ellipse Style="{StaticResource EllipseStyle}"
             Stroke="{Binding Path=Node.Tag,
                      Converter={StaticResource theBooleanBrushConverter}}"
             go:Node.PortId="1"
             go:Node.LinkableFrom="False"
             go:Node.ToSpot="MiddleTop"
             go:SpotPanel.Spot="MiddleTop"
             go:SpotPanel.Alignment="MiddleTop" />
            <Ellipse Style="{StaticResource EllipseStyle}"
             Stroke="{Binding Path=Node.Tag,
                      Converter={StaticResource theBooleanBrushConverter}}"
             go:Node.PortId="2"
             go:Node.FromSpot="MiddleLeft"
             go:Node.ToSpot="MiddleLeft"
             go:SpotPanel.Spot="MiddleLeft"
             go:SpotPanel.Alignment="MiddleLeft" />
            <Ellipse Style="{StaticResource EllipseStyle}"
             Stroke="{Binding Path=Node.Tag,
                      Converter={StaticResource theBooleanBrushConverter}}"
             go:Node.PortId="3"
             go:Node.FromSpot="MiddleRight"
             go:Node.ToSpot="MiddleRight"
             go:SpotPanel.Spot="MiddleRight"
             go:SpotPanel.Alignment="MiddleRight" />
        </go:SpotPanel>
    </DataTemplate>


    <DataTemplate x:Key="End">
        <go:SpotPanel Style="{StaticResource SpotPanelStyle}" go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"   go:Part.SelectionAdornmentTemplate="{StaticResource BoxNodeAdornmentTemplate}" MouseEnter="Node_MouseEnter" MouseLeave="Node_MouseLeave">
            <go:NodePanel Sizing="Auto" go:SpotPanel.Main="True">
                <go:NodeShape x:Name="Shape" Style="{StaticResource NodeShapeStyle}" go:NodePanel.Figure="{Binding Path=Data.Figure}" Fill="{StaticResource theNodeBrush}" />
                <TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding Path=Data.Text, Mode=TwoWay}"  TextAlignment="Center"/>
            </go:NodePanel>
            <!-- An End node has only three ports, all incoming only.
           Port appearance depends on the Node.Tag property.
           The FromSpot and ToSpot properties control where the link connects.
           The SpotPanel properties control where the port is positioned. -->
            <Ellipse Style="{StaticResource EllipseStyle}"
             Stroke="{Binding Path=Node.Tag,
                      Converter={StaticResource theBooleanBrushConverter}}"
             go:Node.PortId="1"
             go:Node.LinkableFrom="False"
             go:Node.ToSpot="MiddleTop"
             go:SpotPanel.Spot="MiddleTop"
             go:SpotPanel.Alignment="MiddleTop" />
            <Ellipse Style="{StaticResource EllipseStyle}"
             Stroke="{Binding Path=Node.Tag,
                      Converter={StaticResource theBooleanBrushConverter}}"
             go:Node.PortId="2"
             go:Node.LinkableFrom="False"
             go:Node.ToSpot="MiddleLeft"
             go:SpotPanel.Spot="MiddleLeft"
             go:SpotPanel.Alignment="MiddleLeft" />
            <Ellipse Style="{StaticResource EllipseStyle}"
             Stroke="{Binding Path=Node.Tag,
                      Converter={StaticResource theBooleanBrushConverter}}"
             go:Node.PortId="3"
             go:Node.LinkableFrom="False"
             go:Node.ToSpot="MiddleRight"
             go:SpotPanel.Spot="MiddleRight"
             go:SpotPanel.Alignment="MiddleRight" />
        </go:SpotPanel>
    </DataTemplate>



    <DataTemplate x:Key="Label">
        <TextBlock Text="{Binding Path=Data.Text, Mode=TwoWay}" FontSize="12" TextWrapping="Wrap" 
             go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"
             go:Part.SelectionAdorned="True"
             go:Part.SelectionAdornmentTemplate="{StaticResource BoxNodeAdornmentTemplate}"
             go:Part.TextEditable="True" />
    </DataTemplate>



    <!-- the template for racks -->
    <DataTemplate x:Key="Group">
        <Grid go:Node.LocationElementName="area"
        go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}" 
        go:Part.SelectionElementName="area"
        go:Part.Selectable="True"
        go:Part.Movable="True"
        go:Part.Resizable="True"
        go:Part.ResizeCellSize="{Binding Source={StaticResource FlowOptions}, Path=CellSize}" 
        go:Part.ResizeAdornmentTemplate="{StaticResource GroupResizeAdornmentTemplate}"
        go:Part.DragOverSnapEnabled="True"
        go:Part.DragOverSnapCellSpot="BottomRight"
        go:Part.DragOverSnapCellSize="{Binding Source={StaticResource FlowOptions}, Path=CellSize}" 
        go:Part.DropOntoBehavior="AddsToGroup">
            <Grid.RowDefinitions>
                <RowDefinition Height="14" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <TextBlock x:Name="txbGroupText" Text="{Binding Path=Data.Text, Mode=TwoWay}" FontSize="12" FontWeight="Bold" Foreground="Black" HorizontalAlignment="Left" Visibility="Visible"  go:Part.TextEditable="True"/>
            <Border Grid.Row="1" BorderBrush="{Binding Path=Node.IsDropOntoAccepted, Converter={StaticResource theStrokeChooser}}" BorderThickness="1" Background="Transparent">
                <go:GridPattern x:Name="area"   Width="{Binding Path=Data.Width, Mode=TwoWay}" Height="{Binding Path=Data.Height, Mode=TwoWay}" CellSize="{Binding Source={StaticResource FlowOptions}, Path=CellSize}">
                    <Path Stroke="{Binding Path=Node.IsDropOntoAccepted, Converter={StaticResource theStrokeChooser}}"
              StrokeThickness=".5"
              go:GridPattern.Figure="HorizontalLine" />
                    <Path Stroke="{Binding Path=Node.IsDropOntoAccepted, Converter={StaticResource theStrokeChooser}}"
              StrokeThickness=".5"
              go:GridPattern.Figure="VerticalLine" />
                </go:GridPattern>
            </Border>
        </Grid>
    </DataTemplate>



    <!-- A fairly standard LinkTemplate with AvoidsNodes routing,
     a JumpOver curve, and a slight curviness.
     The user can reconnect either end of the link.
     It has a polygon shaped like an arrowhead and a label. -->
    <DataTemplate x:Key="LinkTemplate">
        <go:LinkPanel go:Part.Reshapable="True">
            <go:Link.Route>
                <go:Route Routing="AvoidsNodes" Curve="JumpOver" Curviness="10" RelinkableFrom="True" RelinkableTo="True" />
            </go:Link.Route>
            <Polygon Fill="Black" Points="0 0  8 4  0 8  3 4" go:LinkPanel.Index="-1" go:LinkPanel.Alignment="1 0.5" go:LinkPanel.Orientation="Along" />
            <go:LinkShape x:Name="MyLinkShape" Stroke="Black" StrokeThickness="1"  StrokeDashArray="{Binding Path=Data.StrokeDashArray, Mode=TwoWay}" MouseLeftButtonDown="LinkShape_MouseLeftButtonDown"/>
            <!-- this is the label that is only shown when connected to a Decision node -->
            <go:NodePanel Sizing="Auto" go:LinkPanel.Index="1" go:LinkPanel.Alignment="0 0 2 2" go:LinkPanel.Orientation="None">
                <Path go:NodePanel.Figure="None" />
                <TextBlock Text="{Binding Path=Data.Text, Mode=TwoWay}" TextWrapping="Wrap" go:Part.TextEditable="True" Visibility="{Binding Path=Link, Converter={StaticResource theLabelVisibilityConverter}}"/>
            </go:NodePanel>
        </go:LinkPanel>
    </DataTemplate>

</UserControl.Resources>


<Grid>

    <!--Columns-->
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="110" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    
    
    <!-- Palettes and Diagrams have similar implementations. -->
    <go:Palette x:Name="myPalette" Padding="5" NodeTemplateDictionary="{StaticResource NodeTemplateDictionary}"   >
        <go:Palette.Layout>
            <!-- Setting the Sorting to "Forward" is necessary in order to arrange the Nodes in the order they are declared in the NodesSource. -->
            <go:GridLayout Sorting="Forward"  CellSize="75 5" Spacing="5 5" />
        </go:Palette.Layout>
    </go:Palette>
    
    <!--Splitter-->
    <GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Center" VerticalAlignment="Stretch" />
    
    
    <!-- A Diagram that allows for linking between nodes. It also uses a DataTemplateDictionary for different Node categories. -->
    <go:Diagram x:Name="myDiagram"  Grid.Column="2" Padding="10" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" Background="White"
            NodeTemplateDictionary="{StaticResource NodeTemplateDictionary}" ExternalObjectsDropped="myDiagram_ExternalObjectsDropped" LinkTemplate="{StaticResource LinkTemplate}" GroupTemplate="{StaticResource Group}">
                
        <go:Diagram.DraggingTool>
            <local:CustomDraggingTool DragOverSnapArea="DiagramAndNodes"  DropOntoEnabled="True" />
        </go:Diagram.DraggingTool>
        
    </go:Diagram>
    
    <!-- Buttons-->
    <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top">
        <Button Content="Save XML" Click="Save_Click" x:Name="SaveButton" IsEnabled="True" Margin="0,0,10,0" />
        <Button Content="Load XML" Click="Load_Click" x:Name="LoadButton" IsEnabled="False"  Margin="0,0,10,0"/>
    </StackPanel>
   
</Grid>

XAML.CS:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using System.Globalization;
using System.Xml.Linq;
using Northwoods.GoXam;
using Northwoods.GoXam.Model;
using Northwoods.GoXam.Tool;
using System.ComponentModel;

namespace WpfApplication1
{
public partial class FlowChart : UserControl
{

    public FlowChart()
    {
        InitializeComponent();

        // default to the first template


        // Find the DataTemplateDictionary declared in the .XAML using the FindResource method
        // and add to it a predefined DataTemplate for each category of node in the FlowChart.
        // The use of a different template for different types of Nodes allows for increased visual diversity
        // without depending on excessive data-binding. 
        // For example: "Comment" nodes have no ports and have a solid color fill rather than a gradient.  
        // To reduce the amount of code, categories are defined that encompass many nodes with similar features.
        // "Standard" includes many different but similar kinds of nodes.
        DataTemplateDictionary dtd = Diagram.FindResource<DataTemplateDictionary>(this, "NodeTemplateDictionary");
        dtd.Add("Comment", Diagram.FindResource<DataTemplate>(this, "Comment"));
        dtd.Add("Start", Diagram.FindResource<DataTemplate>(this, "Start"));
        dtd.Add("Standard", Diagram.FindResource<DataTemplate>(this, "Standard"));
        dtd.Add("End", Diagram.FindResource<DataTemplate>(this, "End"));
        dtd.Add("Label", Diagram.FindResource<DataTemplate>(this, "Label"));
        dtd.Add("Group", Diagram.FindResource<DataTemplate>(this, "Group"));

        //myDiagram.InitialPosition
        myDiagram.AllowDrop = true;

        //Initialize myDiagram position
        myDiagram.InitialPosition = new Point(0, 0);





        // set up an initial model for the Diagram
        var model = new GraphLinksModel<MyNodeData, String, String, MyLinkData>();

        // and initialize it from the XML file that is an embedded resource
        String xml = WpfApplication1.MainWindow.Instance.LoadText("SupportData", "xml");
        model.Load<MyNodeData, MyLinkData>(XElement.Parse(xml), "MyNodeData", "MyLinkData");
        model.Modifiable = true;
        model.HasUndoManager = true;
        myDiagram.Model = model;


        model.NodeIsGroupPath = "IsSubGraph"; // node property is true if it’s a group
        model.GroupNodePath = "SubGraphKey";  // node property gets container’s name





        // set up the model for the Palette
        var paletteModel = new GraphLinksModel<MyNodeData, String, String, MyLinkData>();

        // this creates the palette's model's data in code:
        paletteModel.NodesSource = new List<MyNodeData>() {
            new MyNodeData() { Key="Comment",  Text="Comment",  Category="Comment", Figure=NodeFigure.Rectangle},
            new MyNodeData() { Key="Start",    Text="Start",    Category="Start", Figure=NodeFigure.RoundedRectangle},
            new MyNodeData() { Key="Step",     Text="Step",     Category="Standard", Figure=NodeFigure.Rectangle},
            new MyNodeData() { Key="Input",    Text="Input",    Category="Standard", Figure=NodeFigure.Input},
            new MyNodeData() { Key="Output",   Text="Output",   Category="Standard", Figure=NodeFigure.Output},
            new MyNodeData() { Key="Conditional", Text="?",     Category="Standard", Figure=NodeFigure.Diamond },
            new MyNodeData() { Key="Read",     Text="Read",     Category="Standard", Figure=NodeFigure.Ellipse },
            new MyNodeData() { Key="Write",    Text="Write",    Category="Standard", Figure=NodeFigure.Ellipse},
            new MyNodeData() { Key="ManualOperation", Text="Manual Operation", Category="Standard", Figure=NodeFigure.ManualOperation },
            new MyNodeData() { Key="DataBase", Text="DataBase", Category="Standard", Figure=NodeFigure.Database },
            new MyNodeData() { Key="End",      Text="End",      Category="End", Figure=NodeFigure.RoundedRectangle },
            new MyNodeData() { Key="Label",    Text="Label",     Category="Label" },
            new MyNodeData() { Key="Group",    Text="Group",     Category="Group" , Width=30,Height=30}

          };


        myPalette.Model = paletteModel;



    }


    // get access to all of the diagram-wide user-settable parameters
    private FlowOptions Options
    {
        get
        {
            if (_Options == null)
            {
                _Options = this.Resources["FlowOptions"] as FlowOptions;
            }
            return _Options;
        }
    }
    private FlowOptions _Options;

    //Save and load the model data as XML, visible in the "Saved" tab of the Demo
    private void Save_Click(object sender, RoutedEventArgs e)
    {
        var model = myDiagram.Model as GraphLinksModel<MyNodeData, String, String, MyLinkData>;
        if (model == null)
        {
            return;
        }

        XElement root = model.Save<MyNodeData, MyLinkData>("SupportData", "MyNodeData", "MyLinkData");
        //Instead of using a file, just save the text to memory here
        WpfApplication1.MainWindow.Instance.SavedXML = root.ToString();
        LoadButton.IsEnabled = true;
        model.IsModified = false;  
    }
    private void Load_Click(object sender, RoutedEventArgs e)
    {
        var model = myDiagram.Model as GraphLinksModel<MyNodeData, String, String, MyLinkData>;
        if (model == null)
        {
            return;
        } 

        try
        {
            //Instead of using a file, just get the text of memory here
            XElement root = XElement.Parse(WpfApplication1.MainWindow.Instance.SavedXML);
            model.Load<MyNodeData, MyLinkData>(root, "MyNodeData", "MyLinkData");
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }

        model.IsModified = false;
    }


    //Sets the Tag property on a Node object to true
    //when the MouseEnter event is called on the Node's SpotPanel.
    //The binding on the Stroke will change to a Black brush.
    private void Node_MouseEnter(object sender, MouseEventArgs e)
    {
        SetPortsVisible(sender as UIElement, true);
    }

    //Sets the Tag property on a Node object to false
    //when the MouseEnter event is called on the Node's SpotPanel.
    //The binding on the Stroke will change to a Transparent brush.
    private void Node_MouseLeave(object sender, MouseEventArgs e)
    {
        SetPortsVisible(sender as UIElement, false);
    }

    //Used in the above two methods to change the node's Tag property to a specified value.
    private void SetPortsVisible(UIElement uielement, bool visible)
    {
        if (Part.FindAncestor<Palette>(uielement) == null)
        {
            SpotPanel sp = uielement as SpotPanel;
            if (sp == null)
            {
                return;
            } 
            Node n = Part.FindAncestor<Node>(sp);
            if (n == null)
            {
                return;
            } 
            n.Tag = visible;
        }
    }

    private void LinkShape_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        ((LinkShape)sender).StrokeDashArray = new DoubleCollection() { 2 };


        //This will save new link, or use Mode=TwoWay in xaml code
        //Link link = Part.FindAncestor<Link>(sender as UIElement);
       
        //if (link == null)
        //{
        //    return;
        //}
             
        //MyLinkData data = link.Data as MyLinkData;
        //if (data == null)
        //{
        //    return;
        //} 

        //myDiagram.StartTransaction("Modify Link");
        //data.StrokeDashArray = new DoubleCollection() { 2 };
        //myDiagram.CommitTransaction("Modify Link");

    }


    // Make a new object's size be the closest non-zero multiple of ResizeCellSize.
    private void myDiagram_ExternalObjectsDropped(object sender, DiagramEventArgs e)
    {
        Size cellsize = this.Options.CellSize;
        foreach (Node n in myDiagram.SelectedParts)
        {
            if (n == null) continue;
            MyNodeData data = n.Data as MyNodeData;
            double w = cellsize.Width * Math.Round(data.Width / cellsize.Width);
            w = Math.Max(w, cellsize.Width);
            double h = cellsize.Height * Math.Round(data.Height / cellsize.Height);
            h = Math.Max(h, cellsize.Height);
            Rect newb = n.LocationSpot.RectForPoint(data.Location, new Size(w, h));
            data.Width = w;
            data.Height = h;
            n.Move(new Point(newb.X, newb.Y), false);
        }
    }

}


// This custom dragging tool is in place to ensure that only box nodes snap to grids,
// and that groups are not added to other groups
public class CustomDraggingTool : DraggingTool
{
    public override bool IsValidMember(Group group, Node node)
    {
        if (node != null)
        {
            // If the node is a group, we can't add it to another group
            if (node.Category == "Group")
            {
                return false;
            }
           
            // If the box is part of a group
            Group display = node.ContainingSubGraph;
            if (display != null && this.DraggedParts.ContainsKey(display))
            {
                return false;
            } 
        }
        return base.IsValidMember(group, node);
    }

    protected override bool ConsiderSnapTo(Node moving, Point pt, Node snapper, Dictionary<Part, Info> draggedparts)
    {
        // Only box nodes should snap: they have the default Category, the empty string
        if (moving != null && moving.Category == "Group")
        {
            return false;
        }
       
        return base.ConsiderSnapTo(moving, pt, snapper, draggedparts);
    }
}

//The data class representing nodes.
public class MyNodeData : GraphLinksModelNodeData<String>
{
    //The shape of each node
    public NodeFigure Figure
    {
        get { return _Figure; }
        set
        {
            if (_Figure != value)
            {
                NodeFigure old = _Figure;
                _Figure = value;
                RaisePropertyChanged("Figure", old, value);
            }
        }
    }
    private NodeFigure _Figure = NodeFigure.Rectangle;

    //The Width of groups
    public double Width 
    {
        get { return _Width; }
        set
        {
            if (_Width != value)
            {
                double old = _Width;
                _Width = value;
                RaisePropertyChanged("Width", old, value);
            }
        }
    }
    private double _Width = 0;

    //The Height of groups
    public double Height 
    {
        get { return _Height; }
        set
        {
            if (_Height != value)
            {
                double old = _Height;
                _Height = value;
                RaisePropertyChanged("Height", old, value);
            }
        }
    }
    private double _Height = 0;

    public override XElement MakeXElement(XName n)
    {
        XElement e = base.MakeXElement(n);
        e.Add(XHelper.AttributeEnum<NodeFigure>("Figure", this.Figure, NodeFigure.Rectangle));
        e.Add(XHelper.Attribute("Width", this.Width, 450));
        e.Add(XHelper.Attribute("Height", this.Height, 300));

        return e;
    }

    public override void LoadFromXElement(XElement e)
    {
        base.LoadFromXElement(e);
        this.Figure = XHelper.ReadEnum<NodeFigure>("Figure", e, NodeFigure.Rectangle);
        this.Width = XHelper.Read("Width", e, 0);
        this.Height = XHelper.Read("Height", e, 0);
    }
}

//The data class representing links.  Actually, there's nothing to add to the predefine link data class.
public class MyLinkData : GraphLinksModelLinkData<String, String>
{

    public DoubleCollection StrokeDashArray
    {
        get { return _StrokeDashArray; }
        set
        {
            if (_StrokeDashArray != value)
            {
                var old = _StrokeDashArray;
                _StrokeDashArray = value;
                RaisePropertyChanged("StrokeDashArray", old, value);
            }
        }
    }
    private DoubleCollection _StrokeDashArray = new DoubleCollection() { };


    public override XElement MakeXElement(XName n)
    {
        XElement e = base.MakeXElement(n);
        e.Add(XHelper.Attribute("StrokeDashArray", this.StrokeDashArray, new DoubleCollection()));

        return e;
    }

    public override void LoadFromXElement(XElement e)
    {
        base.LoadFromXElement(e);
        this.StrokeDashArray = new DoubleCollection(XHelper.Read("StrokeDashArray", e, new DoubleCollection() { }));
    }

    public MyLinkData()
    {
        this.Text = "Yes";
    }

}

//Link labels are visible when they come from a "Conditional" node
public class LabelVisibilityConverter : Converter
{
    public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        Link link = value as Link;
        if ((link != null) && (link.FromNode != null))
        {
            MyNodeData d = link.FromNode.Data as MyNodeData;

            if ((d != null) && (d.Key.StartsWith("Conditional")))
            {
                return Visibility.Visible;
            }
        }

        return Visibility.Collapsed;
    }
}

// Contains properties to bind to for all of the various options in Flow
public class FlowOptions : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;
    public void OnPropertyChanged(PropertyChangedEventArgs e)
    {
        if (PropertyChanged != null) PropertyChanged(this, e);
    }


    public Size CellSize
    {
        get { return _CellSize; }
        set { _CellSize = value; OnPropertyChanged(new PropertyChangedEventArgs("CellSize")); }
    }
    private Size _CellSize = new Size(25, 25);
}

}

With a quick look I don’t see anything wrong.

The main requirements are that the group DataTemplate sets go:Part.DropOntoBehavior=“AddsToGroup” and that the Diagram.DraggingTool sets DropOntoEnabled=“True”.

Overriding the DraggingTool.IsValidMember method is probably needed if you want to control what kinds of parts can go into your groups. Perhaps you should set a break-point there to make sure IsValidMember is returning the correct value.

I found the problem in my code:

CORRECT:

new MyNodeData() { Key=“Group”, Text=“Group”, Category=“Group” , IsSubGraph=true, Width=30,Height=30}

ERROR:

If you see the code again, I didn´t set IsSubGraph=true

new MyNodeData() { Key=“Group”, Text=“Group”, Category=“Group” , Width=30,Height=30}

Thanks!