title: How to automatically scroll to the bottom of an HTML document loaded in a WebBrowser or Frame?
body: <p>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 <strong>I need to automatically scroll to the bottom of the document after the browser refreshes and changes have been rendered</strong>.</p>
  
  <p>I have the code to scroll to the bottom:</p>
  
  <pre><code>(this.browser.Document as HTMLDocument).body.scrollIntoView(false);
  </code></pre>
  
  <p>The issue is that <strong>I've tried many events, and all of them fire BEFORE the web browser control has actually finished rendering the updated source</strong>, 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?  <strong>How can I know when the new content is COMPLETELY finished displaying so that I can scroll to the bottom of it?</strong></p>
  
  <p>EDIT: I tried enclosing a Frame inside a ScrollViewer:</p>
  
  <pre><code>&lt;ScrollViewer x:Name="scrollBar" Grid.Row="1" Grid.Column="0"&gt;
      &lt;Frame Name="browserBox" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" NavigationUIVisibility="Hidden"/&gt;
  &lt;/ScrollViewer&gt;
  </code></pre>
  
  <p>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.  :(</p>