I use WPF rich text box to log data process:
<ScrollViewer>
<RichTextBox x:Name="rtbLog" IsReadOnly="True" />
</ScrollViewer>
Code-behind I use BackgroundWorker to process data and update log by ProgressChanged event handler:
Private Sub WorkerReport(sender as Object, e as ProgressChangedEventArgs) Handles Worker.ProgressChanged
Dim para as New Paragraph
para.Inlines.Add(New Run(...some data))
rtbLog.Document.Blocks.Add(para)
rtbLog.ScrollToEnd()
End Sub
New data is appends successfully, but RichTextBox don't scrolls to end.
What is the problem, why my solution is not working?
Thank you for any advise.
I've understood my mistake. While RichTextBox is wrapped by ScrollViewer, it is not scroll by ScrollToEnd(). After I deleted ScrollViewer, it's works normally.