Updating Group Bounds bug?

Hi

This is for Silverlight 5 + GoXam 1.3.4.5

I have the following the tree structure enclosed by the group ‘Grouper’:

I then collapse the root node ‘Accounts Payable’. I would expect the group to shrink appropriately but instead it remains as is:

However, if I select the group it then shrinks as expected:

The same behaviour applies when expanding nodes. If I expand the collapsed ‘Accounts Payable’ node the group does not update it’s bounds. The group only updates it’s bounds if I select it. My question is: is this by design? If so, how can I force the group to update it’s bounds when one of it’s child nodes is collapsed/expanded?

I have noticed another behaviour which I believe to be a bug. Assumes the diagram is in the state depicted by the first image in this post. I then collapse the ‘Administration Expenses’ node. I then collapse the ‘Accounts Payable’ node. I then expand the ‘Accounts Payable’ node. The group plots the outbound links for the collapsed ‘Administration Expenses’ node which can be seen below:

Thanks
Justin

Do you make all changes within a transaction?

Hi Walter

Yes, here is the code that I use for collapsing/expanding nodes:

protected virtual void ExpandNodeTree(Node node)
{

        if(node == null)
            throw new ArgumentNullException("node");

        var diagram = node.Diagram;
        diagram.StartTransaction("CollapseExpand");
        node.IsExpandedTree = !node.IsExpandedTree;
        diagram.CommitTransaction("CollapseExpand");
    }

I can’t explain the odd behaviors you are seeing.
Could you provide the template definition for your Group?
Is that ExpandNodeTree method the only code (besides model initialization, of course)?

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");

If I modify the ExpandNodeTree method to the following:

protected virtual void ExpandNodeTree(Node node)
{

        if(node == null)
            throw new ArgumentNullException("node");

        var diagram = node.Diagram;
        diagram.StartTransaction("CollapseExpand");
        node.IsExpandedTree = !node.IsExpandedTree;
        diagram.CommitTransaction("CollapseExpand");

<span =“apple-tab-span”="" style=“white-space:pre”> node.ContainingSubGraph.Remeasure();
}

then the group starts to recalculate it’s bounds as expected. However, the behaviour of links being displayed when they shouldn’t still persists:

Actually, the problem is that the default Group.Layout has its LayoutDiagram.Conditions set to the default value, which is LayoutChange.Standard. This set of flags does not include LayoutChange.VisibleChanged.
So I suspect that if you specify the Group.Layout in your Group DataTemplate, it will do the right thing automatically.
<Border . . .>
<Group.Layout>
<go:DiagramLayout Conditions=“Standard VisibleChanged” />
</Group.Layout>
. . .

I still cannot explain how the child link is made visible when the child node is not.

I did as you suggested and modified my template as follows:

Unfortunately, this did not fix the group bounds issue. I still have to manually call node.ContainingSubGraph.Remeasure();

Would you like me to a provide a VS2010 solution to repo the hidden node link issue? Perhaps I’m doing something dodgy that I can’t see

Yes, that would be helpful. Let’s take this discussion off the forum and into e-mail.

Cool, which email address should I use? admin _ nwoods.com?

No, use GoXam at our domain.

Hi Walter

I’ve emailed the solution to the GoXam at your domain address with a subject of ‘Updating Group Bounds Bug’. Can you confirm if you’ve received it?

Got it.