Reloading saved diagram

4 posts, 0 answers
  1. Craig
    Craig avatar
    2 posts
    Member since:
    Jun 2009

    Posted 12 Apr 2012 Link to this post

    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>  
       </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 />


  2. Alex Fidanov
    Alex Fidanov avatar
    637 posts

    Posted 17 Apr 2012 Link to this post


     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 >>

  3. Tairin Hahn
    Tairin Hahn avatar
    6 posts
    Member since:
    Jun 2012

    Posted 12 Jul 2012 Link to this post


    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.

  4. Miro Miroslavov
    Miro Miroslavov avatar
    588 posts

    Posted 17 Jul 2012 Link to this post

    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.

    Miro Miroslavov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top