UWP - TextBox ScrollBar example

MainPage.xaml

<Page
    x:Class="UniversalAppTutorials.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:UniversalAppTutorials"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    >
    <StackPanel Padding="50" Background="AliceBlue">
        <TextBox
            x:Name="TextBox1"
            PlaceholderText="Input some names here"
            Header="Names"
            Margin="5"
            AcceptsReturn="True"
            TextWrapping="Wrap"
            MaxHeight="100"
            ScrollViewer.VerticalScrollBarVisibility="Auto"
            />
        <TextBox
            x:Name="TextBox2"
            PlaceholderText="Input some colors here"
            Header="Colors"
            Margin="5"
            MaxHeight="125"
            />
    </StackPanel>
</Page>
MainPage.xaml.cs

using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml;


namespace UniversalAppTutorials
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            UpdateSecondTextBox();
        }

        // Set the second TextBox properties
        void UpdateSecondTextBox()
        {
            // Allow multiline input for second TextBox
            TextBox2.AcceptsReturn = true;
            TextBox2.TextWrapping = TextWrapping.Wrap;

            // Set the TextBox vertical scroll bar visibility programmatically
            ScrollViewer.SetVerticalScrollBarVisibility(
                    TextBox2, 
                    ScrollBarVisibility.Auto
                );
        }
    }
}
More uwp tutorials