Silverlight 4 Features – Print

One of  Silverlight’s most requested features – Print makes its debut with Silverlight 4. Silverlight’s Print functionality allows you to specify a XAML tree to print. The primary class for printing is the PrintDocument class which exposes several events which are used to call back ask how to print individual pages:

PrintDocument printDoc = new PrintDocument();
printDoc.DocumentName = "SilverLight 4 Demo Print";
printDoc.StartPrint += new EventHandler<StartPrintEventArgs>(printDoc_StartPrint);
printDoc.PrintPage += new EventHandler<PrintPageEventArgs>(printDoc_PrintPage);
printDoc.Print();

The PrintDocument class allows the wire of up pre- and post-print events to prepare and clean-up code.  The important element is PrintPage where the UIElement to print is passed to the PrintDocument object.  This UIElement be something in the visual tree  or something created virtually in-memory and not added to the visual tree.

This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>