I have a FlowDocumentPageViewer control in my application that programmatically advances through each block and inline element in a FlowDocument (this is because it’s part of a typing application and doing so gives visual cues which tell the user what to type). Each time I change the inline element I’m focused on, I want to check what page the inline element is on, and if it’s not on the current page, to navigate to the page it is on.
If this is not possible, please suggest any alternate solutions.
Also, if it matters, every inline element I’m dealing with is a Run element.
Are you just trying to automatically navigate to the page? If so we don’t need to know the page number and should be able to just use BringIntoView? I’m assuming you have a reference to the block?
The following code navigates to the page the 301st block is on when the button is pressed
If you really, really want the page number you could do:
It didn’t flicker or anything in the test app lol! My mate didn’t like that though so he suggested:
Just be aware that it is 0 indexed as opposed to the “lol” method which starts at 1