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

mic*_*ael 6 printing wpf landscape

发现这个功能在线,效果很好......除了我无法弄清楚如何默认它在横向打印.

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

如何实际设置默认值以将我的wpf内容打印到横向模式?

Bad*_*boy 9

private void PrintClick(object sender, RoutedEventArgs e)
{
    PrintDialog dialog = new PrintDialog();
    if (dialog.ShowDialog() == true)
    { 
==>     printDialog.PrintTicket.PageOrientation = PageOrientation.Landscape;
        dialog.PrintVisual(_PrintCanvas, "My Canvas"); 
    }
}
Run Code Online (Sandbox Code Playgroud)