Problems exporting multiple diagrams contained in different RadPanes

2 posts, 0 answers
  1. Kim
    Kim avatar
    6 posts
    Member since:
    Dec 2013

    Posted 19 Mar 2015 Link to this post


    We have a scripting solution, which generates content for diagrams. The generated diagram content is published to a view model, which is bound to a RadDiagram component that is opened inside a docked RadPane by the script. The purpose of the script is to generate a possibly large number of diagrams, and then export each diagram to a file. What happens upon script execution is that each generated diagram is correctly opened in a docked RadPane, but the ExportToFile -method only works for the diagram that is created as the last one, ie the one that exists on the last opened RadPane, ie the only one that is actually visible. All other diagrams are generated as empty files.

    In the script, the export command is invoked immediately after the RadDiagram has been shown, and specifically (hopefully) before the next RadDiagram (that covers the previous one) is being generated, so the diagram to be exported should be visible when the export command is invoked.

    I found other threads having to do with the diagram control not being part of the visual tree, and this may be a related issue.

    Help appreciated,

    Kim Johnsson
  2. Petar Mladenov
    Petar Mladenov avatar
    2991 posts

    Posted 20 Mar 2015 Link to this post

    Hi Kim,

    We are not exactly sure how is you application configured but one is sure - to export the diagram successfully it must have been property measured and arranged in a Visual Tree. 

    If your application cannot stick to this rule, you can try an approach in which you force the measure and arrange of the Diagram inside a parent UserControl and export it without displaying it anywhere.
    var diagram = new RadDiagram();
    diagram.Items.Add(new RadDiagramShape() { Position = new Point(50, 100) });
    diagram.Items.Add(new RadDiagramShape() { Position = new Point(30, 200) });
    diagram.Items.Add(new RadDiagramShape());
    var userControl = new UserControl();
    userControl.Content = diagram;
    userControl.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
    userControl.Arrange(new Rect(0, 0, diagram.DesiredSize.Width, diagram.DesiredSize.Height));
    using (var stream = File.Open(@"D:\temp2\xDiagram2.png", FileMode.Create))

    We hope this could fit well in your scenario.

    Petar Mladenov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top