1

Has anyone ran into problem where you just can't use the PageOrientation property in your C# WPF project? I have tried everything, put it still says:

"The name 'PageOrientation' does not exist in the current context".

I have all usings included, just can't figure it out.

Here's my printing method:

private void btnPrindi_Click(object sender, RoutedEventArgs e)
{
    PrintDialog prtDlg = new PrintDialog();
    if (prtDlg.ShowDialog() == true)
    {
        **prtDlg.PrintTicket.PageOrientation = PageOrientation.Landscape;**

        Size pageSize = new Size(prtDlg.PrintableAreaWidth - 30, prtDlg.PrintableAreaHeight - 30);
        gridKaart.Measure(pageSize);
        gridKaart.Arrange(new Rect(15,15,pageSize.Width,pageSize.Height));
        prtDlg.PrintVisual(gridKaart,"Patsiendikaart");

    }  
}
Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Marek
  • 261
  • 4
  • 14

1 Answers1

1

The error actually refers to the enumeration (PageOrientation.Landscape) on the right hand side of your assignment.

If the property did not exist you would receive (try compiling "".Y and you'll see what I mean):

'string' does not contain a definition for 'Y' and no extension method 'Y' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)

Compare this to Aoeui.Dhtns:

The name 'Aoeui' does not exist in the current context

You are likely missing a namespace reference required, like System.Printing:

// ...
using System.Printing;
// ...

The other possibility is you have not referenced ReachFramework.

If you have, your code compiles as-is:

Seems to work

user7116
  • 63,008
  • 17
  • 141
  • 172