简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM