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;