Provides printing capabilities for a Silverlight application.
Assembly: System.Windows (in System.Windows.dll)
Thetype exposes the following members.
|CheckAccess||Determines whether the calling thread has access to this object. (Inherited from DependencyObject.)|
|ClearValue||Clears the local value of a dependency property. (Inherited from DependencyObject.)|
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)|
|GetAnimationBaseValue||Returns any base value established for a Silverlight dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject.)|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|GetValue||Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|Print(String)||Starts the printing process for the specified document by opening the print dialog box.|
|Print(String, PrinterFallbackSettings, Boolean)||Starts the vector printing process for the specified document by optionally opening the print dialog box or printing directly to the default printer for trusted applications.|
|PrintBitmap||Starts the bitmap printing process for the specified document by opening the print dialog box.|
|ReadLocalValue||Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.)|
|SetValue||Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
|BeginPrint||Occurs after the Print method is called and the print dialog box successfully returns, but before the PrintPage event is raised.|
|EndPrint||Occurs when the printing operation is passed to the print spooler or when the print operation is cancelled by the application author.|
|PrintPage||Occurs when each page is printing.|
The class provides printing capabilities from a Silverlight application. To open a print dialog box call the Print method.
In Silverlight 5 the printing defaults to vector printing. In Silverlight 4, the printing defaults to bitmap printing. You can specify bitmap printing in Silverlight 5 by using the PrintBitmap method.
To specify the content to print, handle the PrintPage event. Inside the method that handles this even you specify the content to print. For either vector or bitmap printing you set the PrintPageEventArgs.PageVisual property to the element you want to print. If you are printing items that are not in the visual tree, you should populate the UIElement with all of its content first and then assign it as the PageVisual. This will cause the layout to recalculate for printing purposes.
For bitmap printing, you can print the entire Silverlight control by setting the PrintPageEventArgs.PageVisual property to the layout root of the Silverlight content. Alternatively, you can print a portion of the Silverlight control by setting PrintPageEventArgs.PageVisual that contains the items you want to print to the named UIElement that you want to print.
After the PrintPage event occurs, the specified PrintPageEventArgs.PageVisual will be sent to the printer to be printed. If the content is too large to fit in the PrintableArea, it will be clipped. If the HasMorePages property is true, the PrintPage event occurs multiple times until HasMorePages is false.
Use the BeginPrint event to perform special handling or set up before printing begins. Use the EndPrint event for clean up or other operations after printing is complete or to detect errors that occurred during the printing process with the EndPrintEventArgs.Error property.
Partial Public Class MainPage Inherits UserControl Private pd As PrintDocument() Public Sub New() InitializeComponent() pd = New PrintDocument() End Sub Private Sub PrintButton_Click(ByVal sender As Object, _ ByVal e As RoutedEventArgs) pd.Print("M yMap") End Sub Private Sub pd_PrintPage(ByVal sender As Object, _ ByVal e As PrintPageEventArgs) Handles pd.PrintPage e.PageVisual = mapImage End Sub End Class
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.