Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8070013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:15:27+00:00 2026-06-05T13:15:27+00:00

I have a FlowDocumentPageViewer control in my application that programmatically advances through each block

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:15:28+00:00Added an answer on June 5, 2026 at 1:15 pm

    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

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
    
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
        }
    
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            FlowDocument fd = new FlowDocument();
    
            for (int i = 0; i < 1000; i++)
            {
                fd.Blocks.Add(new Paragraph(new Run(i.ToString())));
            }
    
            view.Document = fd;
        }
    
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            (view.Document as FlowDocument) .Blocks.Skip(300).First().BringIntoView();
        }
    
    }
    

    If you really, really want the page number you could do:

    var previousPage = view.MasterPageNumber;
    
    (view.Document as FlowDocument) .Blocks.Skip(300).First().BringIntoView();
    
    var pageOfControl = view.MasterPageNumber;
    
    view.GoToPage(previousPage);
    

    It didn’t flicker or anything in the test app lol! My mate didn’t like that though so he suggested:

    var ddp = (DynamicDocumentPaginator)view.Document.DocumentPaginator;
    var position = ddp.GetObjectPosition(document.Blocks.Skip(300).First());
    var page = ddp.GetPageNumber(position);
    

    Just be aware that it is 0 indexed as opposed to the “lol” method which starts at 1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have data that has this kind of structure. Will be in ascending order by
Have data that has this kind of structure: $input = [ { animal: 'cat',
Have some dates in my local Oracle 11g database that are in this format:
I have a FlowDocument in a standard WPF application window where I have some
Have the following problem example . The problem is that because of the border
have a php code like this,going to convert it in to C#. function isValid($n){
Have a network location that shows paths in the 8.3 short format. I need
Have converted devise new session from erb to Haml but doens't work, this is
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:
Have a bunch of WCF REST services hosted on Azure that access a SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.