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 (...)
{
....
graphSource.AddNode(newShape);
UndoableDelegateCommand addShape = new UndoableDelegateCommand(CommandNames.AddShape,
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.
Regards,
Milena
Telerik
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.