Saving shape type

2 posts, 0 answers
  1. Scott Waye
    Scott Waye avatar
    111 posts
    Member since:
    Nov 2009

    Posted 14 Sep 2012 Link to this post

    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
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 18 Sep 2012 Link to this post

    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.

  3. DevCraft banner
Back to Top