Printing in Silverlight 4

Posted by Number8 on Stack Overflow See other posts from Stack Overflow or by Number8
Published on 2010-04-30T14:34:59Z Indexed on 2010/04/30 14:37 UTC
Read the original article Hit count: 198

Filed under:

Hello,

We have an application structured roughly like this:

<Grid x:Name="LayoutRoot">
  <ScrollViewer>
<Canvas x:Name="canvas">
  <StackPanel> < Button /><Slider /><Button /></StackPanel>
  <custom:Blob />
  <custom:Blob />
  <custom:Blob />
</Canvas>
  </ScrollViewer>
</Grid>

Each Blob consists of 1 or more rectangles, lines, and text boxes; they are positioned anywhere on the canvas.

If I print the document using the LayoutRoot:

PrintDocument pd = new PrintDocument();
pd += (s, pe) => { pe.PageVisual = LayoutRoot; };
pd.Print("Blobs");

... it is like a print-screen -- the scrollbars, the sliders, the blobs that are visible -- are printed.

If I set PageVisual = canvas, nothing is printed.

How can I get all the blob objects, and just those objects, to print? Do I need to copy them into another container, and give that container to PageVisual? Can I use a ViewBox to make sure they all fit on one page?

Thanks for any pointers....

© Stack Overflow or respective owner

Related posts about silverlight-4.0