Print a Control, User Control, or Window in WPF
In WPF, a Visual is an object that is parent class of all user interfaces including UIElement, Containers, Controls, UserControls, and even Viewport3DVisual. If you notice all control or user controls classes, they are inherited from a UIElement class.
The PrintVisual print a Visual object. That means, by using the PrintVisual method, we can print any control, container, Window or user control.
The following code snippet in creates a PrintDialog object and calls its PrintVisual method by passing a UserControl to print the UserControl. Using this method, we can print any controls in WPF including a Window, page, or a ListBox.
- PrintDialog printDlg = new PrintDialog();
- UserControl1 uc = new UserControl1();
- printDlg.PrintVisual(uc, "User Control Printing.");
What if you want to print a Grid control or any other control?
As said above, printing any control in WPF is same process. Just pass the Grid or other control in the PrintVisual method of PrintDialog.
- PrintDialog printDlg = new PrintDialog();
- printDlg.PrintVisual(grid1, "Grid Printing.");
How about printing the entire Window?
For entire window, you can either pass the window object or this keyword. This time, you pass "this" that is the object of current Window where you are writing this code.
- PrintDialog printDlg = new PrintDialog();
- printDlg.PrintVisual(this, "Window Printing.");

Andrew WellingPosted May 14, 2015, 5:48 AM
Scratch my last; if you pass your window object into your VM then don't use a 'new' copy of it for your print as you'll end up executing in a new VM thread which is divorced from your view (doh!).
Andrew WellingPosted May 13, 2015, 12:57 PM
Don't you find that if you print a window that the related ViewModel no longer updates the Window View? Events and data etc function normally in the VM but it is as if the DataContext has detached itself (although it hasn't). The view is also functional (not frozen) but doesn't respond to updates in the VM. This only occurs after printing.
JackPosted May 1, 2012, 9:17 AM
How can print multiple records of a listview. PrintVisual only provide image of a specific size or view (where you stand at a time). Please help to print multiple records with the help of printvisual or any other method. i'm new in wpf please explain in brief if any one know(My listview binds with other user control and repeat this use control according to data size)
ernst kuglerPosted Jul 13, 2011, 10:10 AM
how can I print the window in landscape without opening the print dialog?
TomPosted May 24, 2011, 12:14 AM
As of VS 2008 Microsoft appears to have dropped the PrintVisual method from the PrintDialog class. Another example of a reason not to upgrade all of the time.