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

How to print a RadPane?

1 Answer 64 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Pieter
Top achievements
Rank 2
Pieter asked on 22 May 2012, 07:32 AM
I'm trying to print a RadPane using the following code:
public static void PrintHeaderedContentControl(HeaderedContentControl VisualToPrint)
        {
            PrintDialog myPrintDialog = new PrintDialog();
 
            if (myPrintDialog.ShowDialog() == true)
            {
                myPrintDialog.PrintVisual(VisualToPrint, VisualToPrint.Header.ToString());
            }
 
        } // PrintHeaderedContentControl

If I try this with PrintHeaderedContentControl(myRadPane) I just get an empty page with only the header text.
Any Ideas what I can do get this to work?
the following the following

 

It turned out the control was printed but outside the printer paper. So we need to resize and transform the control to get it on paper with code like this:

 

Transform transOld = ControlToPrint.RenderTransform;
                TransformGroup myTransforms = new TransformGroup();
                myTransforms.Children.Add(new ScaleTransform(dScale, dScale));
                myTransforms.Children.Add(new TranslateTransform((myPrintDialog.PrintableAreaWidth - 20) / 20, (myPrintDialog.PrintableAreaHeight - 20) / 20));
 
                ControlToPrint.LayoutTransform = myTransforms;
 
                Size pageSize = new Size(myPrintDialog.PrintableAreaWidth - 20, myPrintDialog.PrintableAreaHeight - 20);
                ControlToPrint.Measure(pageSize);
                ControlToPrint.Arrange(new Rect(10, 10, pageSize.Width - 10, pageSize.Height - 10));
 
                myPrintDialog.PrintVisual(ControlToPrint, Title);
 
                ControlToPrint.LayoutTransform = transOld;

 

1 Answer, 1 is accepted

Sort by
0
Lancelot
Top achievements
Rank 1
answered on 23 May 2012, 11:28 PM
Hi Pieter,

Could you provide me with the xaml you have for that particular rad pane? I have an idea I'd like to test out, but I need to see the exact code block for the at pane. It seems you are only asking for the header to be cast into a string (with VisualToPrint.Header.ToString() )and therefore it will be the only thing passed to the PrintDialog method.

Thanks,
Lancelot
Tags
Docking
Asked by
Pieter
Top achievements
Rank 2
Answers by
Lancelot
Top achievements
Rank 1
Share this question
or