Adding different types of UserControl in diagram based on different shapes

2 posts, 0 answers
  1. Yogendra
    Yogendra avatar
    17 posts
    Member since:
    Aug 2013

    Posted 11 Sep 2013 Link to this post


    I am using RadDiagram control in our Silverlight 5 application where I am facing some issues.

    In the Toolbox, we have five different shapes and I want to drop each one of them in the diagram. Suppose, my toolbox shapes are Shape1, Shape2, ..., Shape5. Now when we drop those shapes in diagram, it will actually drop UserControl1, UserControl2, ..., UserControl5.

    I am unable to find the way to resolve this and hence looking forward for your kind help on this.

    Thanks & Regards,

  2. Pavel R. Pavlov
    Pavel R. Pavlov avatar
    1237 posts

    Posted 16 Sep 2013 Link to this post

    Hi Yogendra,

    I can't be sure how you populate the RadDiagramToolbox with your custom shapes, but I will suggest an approach. You can subscribe to the native Drop event of the RadDiagram control. Furthermore, in its handler you will be able to access the dropped item. Also, you will be able to create your custom control based on the settings of the dropped item.

    You can use similar to the following snippet:

    private void xDiagram_Drop(object sender, DragEventArgs e)
        var shape = e.Data.GetData("Telerik.Windows.Controls.Diagrams.Extensions.RadDiagramToolboxItem");
        if (shape != null)
           //check properties and create custom control

    Please give this approach a try and let us know if this approach works in your scenario.

    Pavel R. Pavlov
    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 >>
Back to Top