This is a migrated thread and some comments may be shown as answers.

Reloading saved diagram

3 Answers 176 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Craig
Top achievements
Rank 1
Craig asked on 12 Apr 2012, 03:02 PM

I created a proj based on your class diagram example.  I wanted to extend this example to save and reload the layout from disk.  I called the diagram Save method and this is the Xml returned (I have removed some attributes for clarity).  My question is when I call diagram Load, how do I re-attach the Model objects to the shapes in the diagrams?  From the Xml below I can see a Shapes content contains the class name of the Model (MyProj.ClassViewModel) that represents that shape.  Do I have to iterate all of the Shapes and set their content?  If so how can I get this xml to store a key for the instance of the model a shape it contains.

Thanks Craig.
 
<?xml version="1.0" encoding="utf-8"?>
 <RadDiagram Type="Telerik.Windows.Diagrams.Core.IGraphInternal" Version="2012.1"> 
  <Metadata Id="601d134b-3a2c-4055-9f7f-78d70597b052"  >  
   <
Title><![CDATA[Diagram [4/12/2012 8:44:45 AM]]]></Title>  
   <
Description><![CDATA[]]></Description> 
    <Background>#00FFFFFF</Background>
   </Metadata>   <Shapes QNs="Telerik.Windows.Controls.Diagrams, Version=2012.1.326.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7;">     <RadDiagramShape Type="Telerik.Windows.Controls.RadDiagramShape" Id="4b632971-9f11-41a8-88b4-67992258e376"  Content="MyProj.ClassViewModel" Geometry="M0,0L60,0 60,40 0,40z" QN="0" />   </Shapes>
   <Connections />
 </RadDiagram>


 

3 Answers, 1 is accepted

Sort by
0
Alex Fidanov
Telerik team
answered on 17 Apr 2012, 09:30 AM
Hi,

 Currently, this is not possible when using the GraphSource. However, for Q2 2012, we have extended the MVVM support to provide a two-way connection between the diagram and the viewmodels as well as serialization support.

The two-way connection is a mechanism that allows the diagram to notify the items source when a shape or connection has been added through the diagram's UI, so that the items source can be updated propertly.

The serialization mechanism represents a way to serialize the whole (view)model or some unique ID into the serialization xml string when saving the diagram and to deserialize it from the serialization xml string when the diagram is loaded.

We are going to have some examples and articles with these new functionalities, so stay tuned for the release.

Please let me know if you have further questions on the matter.

Kind regards,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Tairin Hahn
Top achievements
Rank 1
answered on 12 Jul 2012, 09:35 PM
Hi,

Could you confirm it has been updated for Q2 release??
Still, any node is not saved ( using diagram.Save() ) when I load the nodes MVVM as GraphSource in raddiagram.
I am using Q2 released one and binding the model two way mode.

Thanks, 
0
Miro Miroslavov
Telerik team
answered on 17 Jul 2012, 11:35 AM
Hello Tairin Hahn,

 You may have a look at the Two Way MVVM section in the Data binding help article. But if you need Serializable source that is two way data bound, you'll have to use the SerializableGraphSourceBase<TNode, TLink> abstract class and inherit your source from it. (that is part of the Extensions assembly)
We still don't have article for this but it is easy to use approach. 
Please let us know if you have any issues with this.

Regards,
Miro Miroslavov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Diagram
Asked by
Craig
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Tairin Hahn
Top achievements
Rank 1
Miro Miroslavov
Telerik team
Share this question
or