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

Saving shape type

1 Answer 78 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Scott Waye
Top achievements
Rank 2
Iron
Veteran
Iron
Scott Waye asked on 14 Sep 2012, 07:47 PM
Hi, I have created a set of custom shapes extending RadDiagramShape and I want to be able to recognize which shape is which after the shapes have been dragged from a RadDiagramToolbox on to the diagram and the diagram saved and later loaded.  So I am thinking I can store the type of the shape in the Tag property and add seriliazation events to store and retrieve this property.  However the problem is setting this property on the created shape when the shape from the toolbox is dropped on the diagram.   How can I do that?  Is there an event where I have access to the shape instance or type from the toolbox and the shape created in the RadDiagram Items collection?

I want to do something like:
var bpmnGallery = new Gallery
                      {
                          Header = "BPMN",
                      };
bpmnGallery.Items.Add(new GalleryItem("Start", new BpmnStartShape()));

and then later

shapeThatsGoingToBeAddedToTheDiagram.Tag = MyShapeClassFromTheToolbox.Tag;

Update:

I found this post which solves this problem:
http://www.telerik.com/community/forums/silverlight/diagram/implementing-drag-drop-in-mvvm.aspx


Thanks,

Scott

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 18 Sep 2012, 07:10 AM
Hello Scott,

 We are glad to know you have resolved this scenario. However, we just want to mention that you are able to know when a Shape is being Added via the ItemsChanged event of the RadDiagram:

void diagram_ItemsChanged(object sender, DiagramItemsChangedEventArgs e)
        {
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
            {
              
            }          
        }

Kind regards,
Petar Mladenov
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

Tags
Diagram
Asked by
Scott Waye
Top achievements
Rank 2
Iron
Veteran
Iron
Answers by
Petar Mladenov
Telerik team
Share this question
or