<Window x:Class="WPF控件_8_ScrollViewer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Title="MainWindow" Height="100" Width="800">

    <!-- VerticalScrollBarVisibility  枚举值来自： ScrollBarVisibility
    Disabled：不显示滚动条
    Auto
    Hidden：会隐藏滚动条，但是会滚动只是看不到滚动条
    Visible
     -->

    <StackPanel>
        <StackPanel Orientation="Horizontal">
            <Button Name="LineUpButton" Margin="3" Click="LineUpButton_OnClick">LineUpButton</Button>
            <Button Name="LineDownButton" Margin="3" Click="LineDownButton_OnClick">LineDownButton</Button>
            <Button Name="PageUpButton" Margin="3" Click="PageUpButton_OnClick">PageUpButton</Button>
            <Button Name="PageLeftButton" Margin="3" Click="PageLeftButton_OnClick">PageLeftButton</Button>
        </StackPanel>

        <!-- CanContentScroll="True" 每次滚动会滚动到每个元素开头 -->
        <ScrollViewer VerticalScrollBarVisibility="Auto" Name="MyScrollViewer" CanContentScroll="True" Height="50">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="30" />
                    <RowDefinition Height="30" />
                    <RowDefinition Height="30" />
                    <RowDefinition Height="30" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Label Grid.Row="1" Grid.Column="0" Margin="3" VerticalAlignment="Center">Home: </Label>
                <TextBox Grid.Row="1" Grid.Column="1" Margin="3" Height="Auto" VerticalAlignment="Center" />
                <Button Grid.Row="1" Grid.Column="2" Margin="3" Padding="2" Content="000" />

                <Label Grid.Row="2" Grid.Column="0" Margin="3" VerticalAlignment="Center">搜索：</Label>
                <TextBox Grid.Row="2" Grid.Column="1" Margin="3" Height="Auto" VerticalAlignment="Center" />
                <Button Grid.Row="2" Grid.Column="2" Margin="3" Padding="2">预览</Button>

                <Label Grid.Row="3" Grid.Column="0" Margin="3" VerticalAlignment="Center">看看：</Label>
                <TextBox Grid.Row="3" Grid.Column="1" Margin="3" Height="Auto" VerticalAlignment="Center" />
                <Button Grid.Row="3" Grid.Column="2" Margin="3" Padding="2">预览</Button>
            </Grid>
        </ScrollViewer>
    </StackPanel>
</Window>