29.1. Basic Printing

Although WPF includes dozens of print-related classes (most of which are found in the System.Printing namespace), there's a single starting point that makes life easy: the PrintDialog class.

The PrintDialog wraps the familiar Print dialog box that lets the user choose the printer and a few other standard print options, such as the number of copies (Figure 29-1). However, the PrintDialog class is more than just a pretty window—it also has the built-in ability to trigger a printout.

Figure 29.1. Showing the PrintDialog

To submit a print job with the PrintDialog class, you need to use one of two methods:

  • PrintVisual() works ...

Get Pro WPF in C# 2010: Windows Presentation Foundation in .NET 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.