SerializableGraphSourceBase and undo

2 posts, 0 answers
  1. Rajkumar
    Rajkumar avatar
    9 posts
    Member since:
    May 2014

    Posted 05 Sep 2014 Link to this post

    I derived out my class based on SerializableGraphSourceBase.

    When I add shape to diagram using AddNode, and I try to undo, the shape still exists on the diagram.

    How do i specify so as to consider the AddNode action for undo redo ?
  2. Milena
    Milena avatar
    226 posts

    Posted 08 Sep 2014 Link to this post

    Hi Rajkumar,

    When using GraphSourceBase and add a shape through AddNode(), before performing the undo method 
    you should notify the diagram for that action and update the Undo/RedoStack of the RadDiagram. You can achieve this by using UndoRedoService and UndoableDelegateCommand like so: 

    private void AddShape (...)
       UndoableDelegateCommand addShape = new UndoableDelegateCommand(CommandNames.AddShape,
        c =>
        c =>


    You can notice that I've used:
    - static class CommandNames for the name of the UndoableDelegateCommand and 
    - AddNode() and RemoveItem() which comes from SerializableGraphSourceBase. 
    This will allow you to take advantage of the built-in Undo/Redo functionality of the diagram and just register the new action.

    For your convenience I implemented this approach in the attached project. Please take a look at it and let us know if it works for you.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
Back to Top