我只想知道如何在 WPF 中不显示打印对话框的情况下打印流文档。
感谢您的帮助……</p>
您可以使用 PrintDialog 类而不显示对话框(无需调用 ShowModal)
这是您可以更改默认打印机或更改其他设置的方法之一:
using System.Printing; //add reference to System.Printing Assembly
//if you want to modify PrintTicket, also add
//reference to ReachFramework.dll (part of .net install)
...
var dlg = new PrintDialog();
dlg.PrintQueue = printer; // this will be your printer. any of these: new PrintServer().GetPrintQueues()
dlg.PrintTicket.CopyCount = 3; // number of copies
dlg.PrintTicket.PageOrientation = PageOrientation.Landscape;
dlg.PrintVisual(canvas);
尝试
PrintDialog dialog = new PrintDialog();
dialog.PrintVisual(_PrintCanvas, "My Canvas");