WPF:如何在横向模式下打印?

WPF:如何在横向模式下打印?,wpf,printing,landscape,Wpf,Printing,Landscape,在线找到,效果很好。。。但我不知道如何将其默认为在横向打印 private void PrintClick(object sender, RoutedEventArgs e) { PrintDialog dialog = new PrintDialog(); if (dialog.ShowDialog() == true) { dialog.PrintVisual(_PrintCanvas, "My Canvas"); } } 如何将默认打印wpf内容设置为横向模式?原始答案 这一

在线找到,效果很好。。。但我不知道如何将其默认为在横向打印

private void PrintClick(object sender, RoutedEventArgs e)
{
  PrintDialog dialog = new PrintDialog();
  if (dialog.ShowDialog() == true)
  { dialog.PrintVisual(_PrintCanvas, "My Canvas"); }
}

如何将默认打印wpf内容设置为横向模式?

原始答案 这一点已经得到回答:

结束原始答案

编辑:

打印票和打印图像似乎有问题,请检查:


MSDN论坛上的原始海报张贴在上一篇帖子上,他们使用的工作基本上是捕捉视觉效果并转换为xps文档进行打印,这将允许使用PrintTicket设置打印文档的方向。

编辑:固定变量名,由@SHIN JaeGuk提及

private void PrintClick(object sender, RoutedEventArgs e)
{
    PrintDialog dialog = new PrintDialog();
    if (dialog.ShowDialog() == true)
    { 
        //Set PageOrientation to Landscape
        dialog.PrintTicket.PageOrientation = PageOrientation.Landscape;
        dialog.PrintVisual(_PrintCanvas, "My Canvas"); 
    }
}

您需要分别添加对ReachFramework.dll和System.Printing.dll的引用。

我不是要打印文档,而是要打印内容。例如,现在我将
(可视)mytabs.SelectedContent
传递到我的
print.printVisual()
方法中。我应该将我的
mytabs粘贴到哪里。在您指向的答案中选择内容
?什么是printDialog?
private void PrintClick(object sender, RoutedEventArgs e)
{
   PrintDialog dialog = new PrintDialog();
   if (dialog.ShowDialog() == true)
      { 
         dialog.PrintTicket.PageOrientation=System.Printing.PageOrientation.Landscape;
         dialog.PrintVisual(this, "First LandScape"); 
      }
 }