Search code examples
avaloniaui

Textbox scroll to bottom in Avalonia


I have a textbox that I write info to that automatically creates a scroll bar when the screen is filled, and I'd like to scroll to the bottom of it. It seems like what I need to do is set the scrollbar Offset to some vector, but my problem is finding the ScrollViewer.

I can't use FindControl because it's not named anywhere in the xaml, and I can only change a few values using textbox.SetValue


Solution

  • The only way to scroll a TextBox currently is to set the CaretPosition. For example to scroll to the end of the text you could use:

    textbox.CaretIndex = int.MaxValue;