title: Make RichTextBox automatically scroll to bottom when content is added
body: <p>I have a WPF UserControl with a <code>BindableRichTextBox</code>:</p>
  <pre class="lang-xml prettyprint-override"><code>xmlns:controls=&quot;clr-namespace:SysadminsLV.WPF.OfficeTheme.Controls;assembly=Wpf.OfficeTheme&quot;
  .
  .
  .
  &lt;controls:BindableRichTextBox Background=&quot;Black&quot;
                                Foreground=&quot;White&quot;
                                FontFamily=&quot;Consolas&quot;
                                FontSize=&quot;12&quot;
                                IsReadOnly=&quot;True&quot;
                                IsReadOnlyCaretVisible=&quot;True&quot;
                                VerticalScrollBarVisibility=&quot;Auto&quot;
                                IsUndoEnabled=&quot;False&quot;
                                Document=&quot;{Binding Contents}&quot;/&gt;
  </code></pre>
  <p>The contents is controlled by a ViewModel property <code>Document</code>:</p>
  <pre class="lang-cs prettyprint-override"><code>using System.Windows.Documents;
  
  class MyViewModel : ILogServerContract 
  {
      readonly Paragraph _paragraph;
  
      public MyViewModel() 
      {
          _paragraph = new Paragraph();
          Contents = new FlowDocument(_paragraph);
      }
  
      public FlowDocument Contents { get; }
  
      //Log Server Contract Write method (accessed via NetPipe)
      public void WriteLine(string text, int debugLevel) 
      {
          //figure out formatting stuff based on debug level. not important
          _paragraph.Inlines.Add(new Run(text) {
              //set text color
          });
      }
  }
  </code></pre>
  <p>As you can see, the RichTextBox <code>Document</code> property is bound to the <code>Contents</code> property from <code>MyViewModel</code>. The <code>Contents</code> property, in turn, is written to via NetPipes by way of the <code>WriteLine()</code> method, which is part of the <code>ILogServerContract</code> interface.</p>
  <p>What I'm struggling with is:</p>
  <ul>
  <li>How to raise an event when the contents of the RichTextBox is updated and then</li>
  <li>Call the <code>ScrollToEnd()</code> method on the RichTextBox as proposed in <a href="https://stackoverflow.com/questions/10308475/how-can-i-make-a-richtextbox-scroll-to-the-end-when-i-add-a-new-line">this simpler problem</a>. Since the RichTextBox is declared in XAML and not code, I'm not sure how to do that.</li>
  </ul>
  <p>Can anyone assist?</p>