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

  • Home
  • SEARCH
  • 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 3281366
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:48:28+00:00 2026-05-17T19:48:28+00:00

I’m using an HTML document to show text output in my application – this

  • 0

I’m using an HTML document to show text output in my application – this gives me the flexibility of HTML and the power of CSS, and I can publish the generated HTML as a log file openable in any browser. When new information is available, I update the HTML file and then call Refresh() on my WebBrowser control. Naturally, I want the user to see the newest information without having to manually scroll down, so I need to automatically scroll to the bottom of the document after the browser refreshes and changes have been rendered.

I have the code to scroll to the bottom:

(this.browser.Document as HTMLDocument).body.scrollIntoView(false);

The issue is that I’ve tried many events, and all of them fire BEFORE the web browser control has actually finished rendering the updated source, so I end up scrolling to the bottom before the new content is displayed! This is incredibly frustrating – does anyone know how to solve this problem? How can I know when the new content is COMPLETELY finished displaying so that I can scroll to the bottom of it?

EDIT: I tried enclosing a Frame inside a ScrollViewer:

<ScrollViewer x:Name="scrollBar" Grid.Row="1" Grid.Column="0">
    <Frame Name="browserBox" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" NavigationUIVisibility="Hidden"/>
</ScrollViewer>

This works fine for application pages (Page class) because the Frame grows large enough to fit the entire page, causing the enclosing ScrollViewer to adjust and fire a ScrollChanged event. I was momentarily very excited, but then discovered that unfortunately, when I load an HTML file into the frame instead, the frame does NOT resize to fit the content, but rather introduces its own scroll bar, so now I’ve got one scroll bar inside of another, and I can’t subscribe to events for the inner scroll bar. 🙁

  • 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-05-17T19:48:29+00:00Added an answer on May 17, 2026 at 7:48 pm

    OMG! I found the answer! Based on a hint I found in this post:

    Wrap a frame with a scroll viewer and subscribe to the frame’s ContentRendered event:

    <ScrollViewer x:Name="scrollViewer">
        <Frame x:Name="frame" Source="pack://siteoforigin:,,,/HTMLPage1.htm" NavigationUIVisibility="Hidden" ContentRendered="Frame_ContentRendered" />
    </ScrollViewer>
    

    On render, measure the HTML content and update the size of the frame (add a reference to .NET assembly Microsoft.mshtml):

    using mshtml;
    
    private void Frame_ContentRendered(object sender, EventArgs e)
    {
        HTMLDocument htmlDoc = ((this.frame.Content as WebBrowser).Document as mshtml.HTMLDocument);
    
        if (htmlDoc != null && htmlDoc.body != null)
        {
            mshtml.IHTMLElement2 body = (mshtml.IHTMLElement2)htmlDoc.body; 
            this.frame.Width = body.scrollWidth; 
            this.frame.Height = body.scrollHeight;
        }
    
        this.scrollViewer.ScrollToEnd();
    }
    

    Finally, eliminate the scroll bar housed within the Frame by disabling scrolling within your HTML document itself:

    <body scroll="no">
    

    Woohoo! I’ll go throw a party now. Scrolling to the bottom of an HTML doc should not have taken a week (but it did).

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

Sidebar

Related Questions

No related questions found

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.