(I sincerely hope this is not a duplicate and I'm not stating the question too convolutedly.)
In your Diagram/MVVM example you demonstrate binding a RadDiagram to a ViewModel including serialization and deserialization with two ViewModel classes derived from NodeViewModelBase (Model, Brand) associated with the diagram's shapes.
The XAML for the diagram defines custom styles for RadDiagramShape and RadDiagramContainerShape which (as explained in your How-To page on StyleSelectors and MVVM) bind their Position dependency property to the (derived, via NodeViewModelBase) Position property of the ViewModel classes.
<Setter Property="Position" Value="{Binding Position, Mode=TwoWay}" />
When the graph is constructed the shapes' positions are indeed taken from the ViewModel classes and when the graph is serialized, so are the positions. The serialized position values can, as expected, be found in the generated XML file.
However, when the graph is deserialized, these values are not retrieved in the DeserializeNode override (see below), neither via a call to NodeViewModelBase.DeserializeNode nor by explicitly querying the "Position" attribute in the XML. The Position property of these NodeViewModelBase-derived objects is still (0,0) upon exit. (Only the (inherited) Content property of the node-related ViewModel classes (Model, Brand) is set from "Content" XML attribute.)
Excerpt from CarsGraphSource.cs:
public override NodeViewModelBase DeserializeNode(IShape shape, Telerik.Windows.Diagrams.Core.SerializationInfo info)
{
NodeViewModelBase node = null;
if (shape is IContainerShape)
{
node = new Brand();
}
else
{
node = new Model();
}
if (info["Content"] != null)
node.Content = info["Content"].ToString();
if (info[this.NodeUniqueIdKey] != null)
{
var nodeUniquekey = info[this.NodeUniqueIdKey].ToString();
this.CachedNodes[nodeUniquekey] = node;
}
return node;
}
Still, after deserialization, the position of the shapes is restored correctly (despite the Position property of the ViewModel classes still being (0,0).
Am I understanding something completely wrong here? Thank you very much in advance for your help.