Custom RadDiagram appearance (styles) for Printing

2 posts, 0 answers
  1. Max
    Max avatar
    6 posts
    Member since:
    Feb 2015

    Posted 03 Mar 2015 Link to this post

    Hello!

    How can I change RadDiagramm appearance in PrintPreview dialog? I was try to make new instance of RadDiagram with custom styles, but it is does not work. PrintPreview is empty. Can you send example, which describe, how to print diagram with custom shape/link styles for printing puporses. Thank you.

    void PrintClick(object sender, ItemClickEventArgs e)
            {
                var printPreviewWindow = new Window();
                var diagramForPrint = new RadDiagram();
                diagramForPrint.GraphSource = diagramm.GraphSource;
                diagramForPrint.Style = diagramm.Style;//here I will set some my PrintStyle
                var printPreview = new RadDiagramPrintPreview() { Diagram = diagramForPrint };
                printPreviewWindow.Content = printPreview;
                printPreviewWindow.ResizeMode = ResizeMode.NoResize;
                printPreviewWindow.Width = 800;
                printPreviewWindow.Height = 600;
                printPreviewWindow.ShowDialog();
            }
  2. Kiril Vandov
    Admin
    Kiril Vandov avatar
    324 posts

    Posted 04 Mar 2015 Link to this post

    Hello Max,

    You can find information on how to print the RadDiagram in our online documentation. This approach will print your diagram which is definer in XAML as you are setting the diagram property of the
    RadDiagramPrintPreview control to the same instance as the diagram defined in XAML.

    However if you want to create a new RadDiagram instance in code behind and try to print it will be displayed as empty page as the diagram is not in the VisualTree and it has never been rendered. If you want to print a RadDiagram this way you will need to manually Measure and Arange it inside a parent control. Here is a modified version of your code snippet:
    var printPreviewWindow = new Window();
            var diagramForPrint = new RadDiagram();
            diagramForPrint.GraphSource = diagramm.GraphSource;
            //diagramForPrint.Style = diagramm.Style;//here I will set some my PrintStyle
     
            var userControl = new UserControl();
            userControl.Content = diagramForPrint;
            diagramForPrint.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            diagramForPrint.Arrange(new Rect(0, 0, diagramForPrint.DesiredSize.Width, diagramForPrint.DesiredSize.Height));
     
            var printPreview = new RadDiagramPrintPreview() { Diagram = diagramForPrint };
            printPreviewWindow.Content = printPreview;
            printPreviewWindow.ResizeMode = ResizeMode.NoResize;
            printPreviewWindow.Width = 800;
            printPreviewWindow.Height = 600;
            printPreviewWindow.ShowDialog();

    If this approach does not work for you, could you please elaborate with more information on your scenario, describing the steps that you want to make and the end result. Also a sample project demonstrating the way you are trying to print the diagram will help us better understand your scenario.

    I hope this information helps.

    Kind regards,
    Kiril Vandov
    Telerik
     

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top