MVVM with RadContainerShape and Undo and Redo

3 posts, 0 answers
  1. Kent
    Kent avatar
    10 posts
    Member since:
    Jan 2012

    Posted 16 Aug 2013 Link to this post

    I am trying to do MVVM with data binding to GraphSource using a ObservableGraphSourceBase.  When I drop a container from the DiagramToolbox.  How would be able to associate that container with view model item and still be able to undo or redo adding that item to the diagram?
  2. Petar Mladenov
    Petar Mladenov avatar
    2986 posts

    Posted 19 Aug 2013 Link to this post

    Hi Kent,

     We prepared a sample project for you which we hope can be a good starting Point. Basically, it is based on our MVVM sample in our XAML GutHub Reporistory. We added a DiagramToolBox in the sample. Please have in mind the following key points:

    • The GraphSource inherits from SerializableGraphSourceBase<NodeViewModelBase, Link> which is a type of ObservableGraphSourceBase which better supports Save / Load scenarios.
    • Brand inherits from ContainerNodeViewModelBase<object>. When you drop a container from the ToolBox, the diagram publishes DeserializeNode  method in the SerializableGraphSourceBase and you can instatntiate an ssociate ViewModel:
    public override NodeViewModelBase DeserializeNode(IShape shape, Telerik.Windows.Diagrams.Core.SerializationInfo info)
                NodeViewModelBase node = null;
                if (shape is IContainerShape)
                    node = new Brand();
    Then it is automatically added to the GraphSource.
    Please check out the application and let us know if you need further assistance. The following help article might also be worth reading.
    How To Serialize a DataBound Diagram

    Petar Mladenov
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. Kent
    Kent avatar
    10 posts
    Member since:
    Jan 2012

    Posted 22 Aug 2013 Link to this post

    Thanks. That sample helped me out.
Back to Top