Data.Location not restored when reload

Hi,

I'm using GoXam for WPF v1.0.7.3, and use DiagramData.Save<...>(..) to persist to a XML file and invoke DiagramData.Load<...>(..) to load persisted XML back to diagram visual. It looks like after the XML loads, even though there is Location persisted with Node data, the diagram always draw the node in the Location of (0,0).
One simpliest example is that I just saved a one-node diagram,
here is the persisted XML content:


Here is my data bound data template for Data.Location in XAML:
<DataTemplate x:Key="Node"> <go:SpotPanel go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}" > <go:NodePanel> <go:NodeShape Width="25" Height="25" ToolTip="{Binding Path=Data.Description}" go:NodePanel.Figure="{Binding Path=Data.Figure}" Fill="Navy" Stroke="{Binding Path=Node.IsSelected, Converter={StaticResource theSelectionConverter}}" StrokeThickness="2" MouseDown="StartNodeDoubleClick" /> </go:NodePanel> <Rectangle go:SpotPanel.Spot="MiddleLeft" Width="8" Height="8" Fill="Black" go:Node.PortId="inPort" go:Node.LinkableTo="True" go:Node.LinkableMaximum="5" go:Node.ToSpot="MiddleLeft" Cursor="Hand" />

<Rectangle go:SpotPanel.Spot=“MiddleRight” Width=“8” Height=“8” Fill=“Black”
go:Node.PortId=“outPort” go:Node.LinkableFrom=“True”
go:Node.LinkableMaximum=“5”
go:Node.FromSpot=“MiddleRight” Cursor=“Hand” />
</go:SpotPanel>
</DataTemplate>

But when reloads, the node shows up at the very left-top corner.
Did I miss anything? Any workaround to correctly restore the node's location?
Appreciate your help.

Perhaps the Location is correct. If you save it, what Location does it have?

If the Location hasn’t changed, it’s probably because the Diagram positioned the contents to be at the top-left corner of the panel. Specify values for the Diagram.HorizontalContentAlignment and VerticalContentAlignment attributes.

When saved, it has location as Location=“202 149” in the XML file.

And the xxxAlignemtn is set as Stretch:
HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
Do I need to correct anything here?

That looks OK to me.

I tried saving and loading a diagram of a single node using the State Chart sample in GoWpfDemo. It worked as you would expect. So I wonder what might be different in your application.

Oh, perhaps you have a Diagram.Layout that is always performing a layout after loading the nodes from XML. In version 1.1 by default you’ll get the behavior that you want. In version 1.0 the easiest solution is not to declare a value in XAML for the Diagram.Layout, but to create it and perform the layout in code only.

My app requires to drag note from palette to the diagram surface to build the diagram, the node needs to stay whereever user drops it, so I made sure there is no Diagram.Layout is set.

I also noticed when the one node XML loads into a Dragram, the note appears at the correct location, then suddenly moves to the left-top corner, behaves like a left-top aligned layout is applied by default.
Do you think there is a work around? Like to programmactically set the Diagram's origin coordinates after reload? Or anything else I can try to tell the Diagram works in "absolute-positioned" mode?
Like always, your help is appreciated.

What you want is the default behavior. That’s why I don’t understand how your application is different from the samples such as State Chart.

Finally!

It turns out I need to set InitialStretch to be Uniform, then the default behavior works as expected.
Thanks.

Hmmm. It should be OK to set Diagram.InitialStretch if that’s what you want, but it shouldn’t be required to get the (default) behavior that you are seeking. The State Chart sample, for example, doesn’t set InitialStretch.