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

Reusable diagram (UserContrl Or Template)

1 Answer 61 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Nitin Nitin
Top achievements
Rank 1
Nitin Nitin asked on 01 Aug 2013, 01:14 PM
Hello,

I am creating a diagram using RadDiagram,RadContainerShapes,RadDaigramShapes,RadConnection

In that diagram, I have repetitive shapes or diagram which currently I have to code and give the position.

Is there any way if creating a template/usercontrol in which you can create daigrams with connections and reuse it in the main diagram page.
This can definitely save my time and the xaml code

Will really appreciate if you share a working solution as an example for this question.

Thanks,
nitin  

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 06 Aug 2013, 08:22 AM
Hi Nitin,

We think the best way to achieve the desired effect from the picture is to create a method which will have a parameter - top left point of the series of Shapes. This method will calculate the positions of the child shapes in this *virtual block of shapes* and add the shapes into Diagram. For example like so:
private void AddVlockOfShapes(Point startPoint)
{
RadDiagramShape first = new RadDiagramShape(){Position = startPoint};
this.diagram.Add(first);
RadDiagramShape second= new RadDiagramShape(){Position = new Point(startPoint.X, StartPoint.Y + 60};
this.diagram.Add(second);
this.diagram.Add(new RadDiagramConnection(){Source = first, Target = second});
...
...
}
You can invoke this method multiple times in Diagram Loaded event handler with different parameter values. Let us know if this moves you in the right direction.

Regards,
Petar Mladenov
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
Nitin Nitin
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or