Group border in wrong place

Hi Walter I need some help!

My layout is base on a Grid layout.

In DoLayout(…) I calculate nodeData position for all elements. First Group get position 0,0, First Node inside the Group get parent position and so on.

My Group template is a simple border is defined with folowing values

  • Group.LocationSpot=“TopLeft”
  • Group.Location="{Binding Data.Location, Mode=TwoWay}"
  • Width="{Binding Data.Width, Mode=TwoWay}"
  • Height="{Binding Data.Height, Mode=TwoWay}"

There is only 1 element inside the border (Main Border) and it’s the GroupPanel (I’ve removed Group layout as the whole layouting is calculated in the Main Layout)
Inside the Group panel I’ve added a Boder bind to the nodeData Size.
I’ve expected that both Rectangle should have been at the exact same position. But I’ve a delta between
Main Border and Group Panel Border.

Why are my border not at the same position?
Why orange border do not have the configuration as it’s parent.

I’ve seen that your virtual project example use Vertex.
Do I need to implement such class? If so how can give to the diagram my own managed Vertex?

Thanks

What is your group template?

<Border CornerRadius="0" 
        x:Name="MainBorder"
        BorderThickness="{Binding Data.ViewModel.IsSelected, Converter={StaticResource trueTo2}}" 
        BorderBrush="{Binding Data.ViewModel.IsSelected, Converter={StaticResource trueToRed}}"            
        gowpf:Group.SelectionAdorned="False"
        gowpf:Group.LocationElementName="myNetworkPanel"
        gowpf:Group.LayerName="{Binding Data.Layer}"
        gowpf:Group.Location="{Binding Data.Location, Mode=TwoWay}"
        gowpf:Group.LocationSpot="TopLeft"
        
        Width="{Binding Data.Width, Mode=TwoWay}"
        Height="{Binding Data.Height, Mode=TwoWay}"            
        SizeChanged="MainBorder_SizeChanged"            
        ContextMenuOpening="Border_OnContextMenuOpening"            
        Background="{Binding Data.ViewModel.ProtocolDefinitionVM, Converter={StaticResource protocolToBrush}}">

  <StackPanel Margin="0" x:Name="MainPanel">
    <StackPanel>          
      <gowpf:GroupPanel x:Name="myNetworkPanel" >
        <Border BorderThickness="2"
                BorderBrush="Orange" Width="{Binding Data.Width}"
                Height="{Binding Data.Height}"/>
      </gowpf:GroupPanel>
    </StackPanel>
  </StackPanel>
</Border>

Really simple. Double stackPanel ist due to all removed elements (Textbox, buttons…)

image
Normally TopLeft corner (orange/grey) rectangle position should have the same position as the NodeData set in the layout algorithm at (0,0).

Look like that Diagram Panel for sub node is centered on this position. Is my observation correct?

It doesn’t make sense to me that you are binding the Width and Height of both the whole group’s Border as well as the Border in the GroupPanel. How can they both be the same size when you have other elements in the StackPanel?

Furthermore, why are you binding the Width and Height of the Border in the GroupPanel? Normally a Border should go around something, but there’s nothing there. It’s most common to have a Border around the GroupPanel, in which case you wouldn’t need or want to bind its Width and Height.

OK you’re right.
With Border around GroupPanel look better.

image