Using the answer from https://code.msdn.microsoft.com/windowsapps/How-to-scroll-to-the-a8ea5867 sometimes caused lines to be deleted when scrolling up.
To fix that, try this:
private void ScrollToBottom(TextBox textBox)
{
var grid = (Grid)VisualTreeHelper.GetChild(textBox, 0);
for (var i = 0; i <= VisualTreeHelper.GetChildrenCount(grid) - 1; i++)
{
object obj = VisualTreeHelper.GetChild(grid, i);
if (!(obj is ScrollViewer)) continue;
((ScrollViewer)obj).ChangeView(0.0f, ((ScrollViewer)obj).ExtentHeight, 1.0f, true);
break;
}
}
The main difference is this line:
((ScrollViewer)obj).ChangeView(0.0f, ((ScrollViewer)obj).ExtentHeight, 1.0f, true);
I also separated the method from the event handler, because I didn't want to necessarily scroll every time the text was changed.