1

I have a simple textbox in UWP to where content is automatically being added. Issue is when text reach the bottom of the textbox, content is still being added but becomes invisible, unless I use the mice to scroll down.

How could I add auto scroll down capability to the textbox?

Trying the ScrollViewer, but to no luck..

    <TextBox x:Name="mainTextBox" Grid.Row="2" Grid.Column="0" Margin="5" ScrollViewer.VerticalScrollMode="Auto" TextWrapping="Wrap" Text="" IsReadOnly="True" />

Here is the code that updates my textbox:

    private void UpdateStatus(string strMessage, NotifyType type)
    {
        mainTextBox.Text += string.IsNullOrEmpty(mainTextBox.Text) ? strMessage : "\n" + strMessage;

        var peer = Windows.UI.Xaml.Automation.Peers.FrameworkElementAutomationPeer.FromElement(mainTextBox);
        if (peer != null)
        {
            peer.RaiseAutomationEvent(Windows.UI.Xaml.Automation.Peers.AutomationEvents.LiveRegionChanged);
        }
    }

What should be done? Can someone by a chance help?

Franck E
  • 629
  • 8
  • 26

1 Answers1

0

This is a duplicate of this post:

UWP C# Scroll to the bottom of TextBox

I have tested and it works perfectly.. :)

Franck E
  • 629
  • 8
  • 26