I am writing a simple application for WinRT and I am having trouble figuring out a way to automatically scroll to the bottom of a TextBox in my code. I am writing log information to a TextBox and would like it to scroll so that the newest entries are visible in the box, but nothing seems to work. Below are a few things I've tried:
Place the TextBox in a ScrollViewer:
this.txtLog.Text = this.txtLog.Text + line + "\r\n";
ScrollToVerticallOffset(scrollView.ScrollableHeight);
Select the last data in the TextBox:
this.txtLog.Select(this.txtLog.Text.Length, 0);
But nothing I do actually causes the displayed text to scroll so that the bottom data is visible.
Does anyone have any ideas?
This works:
XAML
C#
That uses Winrt XAML Toolkit.
Non-toolkit way: