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

Adding different types of UserControl in diagram based on different shapes

1 Answer 66 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Yogendra
Top achievements
Rank 1
Yogendra asked on 11 Sep 2013, 09:57 AM
Hi,

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,
Yogendra

1 Answer, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 16 Sep 2013, 05:29 AM
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.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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 >>
Tags
Diagram
Asked by
Yogendra
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Share this question
or