user3292642
user3292642

Reputation: 761

How to print a wpf control

Im trying to print everything within a wpf control - lets say a grid.
I read about printvisual method, but its not visible to me.

My code looks like this:

private void print(FrameworkElement element)
    {
        PrintDialog printDlg = new PrintDialog();
        printDlg.PrintVisual(element, "this is a test");
    }

and my compiler says does not contain a definition for PrintVisual method. I already included System.Windows.Media.Visual namespace but that didnt help aswell.

Thanks for your help

Upvotes: 0

Views: 486

Answers (1)

Etienne Fesser
Etienne Fesser

Reputation: 172

Maybe you have the wrong using :

using System.Windows.Forms; instead of using System.Windows.Controls;

The PrintDialog is in both but one doesn't have the PrintVisual() method.

Upvotes: 1

Related Questions