0

I have a DocumentViewer which I am setting the Document property to an XPS file

var x = new XpsDocument(tempFile, FileAccess.Read);
            Document = x.GetFixedDocumentSequence();
x.Close();

Having set the document how can I scroll to Page x or to a position y pixels down the document?

EDIT:

I have now amended to:

var x = new XpsDocument(tempFile, FileAccess.Read);
Document = x.GetFixedDocumentSequence();
VerticalOffset = 250;
x.Close();

Now it appears that every other time time it scrolls correctly, but in between it always seems to scroll back to the beginning. This is odd and I can't explain it. Any ideas?

David Ward
  • 3,739
  • 10
  • 44
  • 66

1 Answers1

0

I don't know if this will work for your specific problem, but whenever I need to scroll to a specific point in an XPS document, I have to place the VerticalOffset in the DocumentViewer's Loaded event, otherwise it will attempt to scroll before anything is actually there.

Edit:

I think I have recreated your problem, and you actually want to place your VerticalOffset in the DocumentViewer's LayoutUpdated event, which should hopefully trigger each time you load a new document.

Jason
  • 1
  • 1