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

MVVM with RadContainerShape and Undo and Redo

2 Answers 114 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Kent
Top achievements
Rank 1
Kent asked on 16 Aug 2013, 10:46 PM
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 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 19 Aug 2013, 08:21 AM
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
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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 >>
0
Kent
Top achievements
Rank 1
answered on 22 Aug 2013, 05:36 PM
Thanks. That sample helped me out.
Tags
Diagram
Asked by
Kent
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Kent
Top achievements
Rank 1
Share this question
or