Reusable diagram (UserContrl Or Template)

2 posts, 0 answers
  1. Nitin Nitin
    Nitin Nitin avatar
    41 posts
    Member since:
    Apr 2010

    Posted 01 Aug 2013 Link to this post

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

    Posted 06 Aug 2013 Link to this post

    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 >>
  3. DevCraft banner
Back to Top