SplitView.Content 内的 UWP ScrollViewer 不滚动

UWP ScrollViewer inside a SplitView.Content not scrolling

我正在尝试构建一个 UWP 应用程序,我有以下组件:

主页:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid.RowDefinitions>
        <RowDefinition Height="50"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <StackPanel Name="TituloStackPanel" Orientation="Horizontal">
        <Button Name="HamburguerButton" Content="&#xE700;" FontFamily="Segoe MDL2 Assets" Height="50" Width="50" Click="HamburguerButton_Click"/>
        <TextBlock Name="Titulo" Text="Estrutura de Dados" VerticalAlignment="Center" Margin="10"/>
    </StackPanel>

    <SplitView Name="PrincipalSplitView" DisplayMode="CompactOverlay" IsPaneOpen="False"
               CompactPaneLength="50" OpenPaneLength="200" Grid.Row="1">
        <SplitView.Pane>
            <StackPanel>
                <StackPanel Orientation="Horizontal">
                    <Button Name="ListasButton" Content="L" Width="50" Height="50" Click="ListasButton_Click"/>
                    <TextBlock Text="Listas" VerticalAlignment="Center" Margin="10"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <Button Name="PilhasButton" Content="P" Width="50" Height="50"/>
                    <TextBlock Text="Pilhas" VerticalAlignment="Center" Margin="10"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <Button Name="FilasButton" Content="F" Width="50" Height="50"/>
                    <TextBlock Text="Filas" VerticalAlignment="Center" Margin="10"/>
                </StackPanel>
            </StackPanel>
        </SplitView.Pane>
        <SplitView.Content>
            <TextBlock Text="SplitView Content" VerticalAlignment="Center" HorizontalAlignment="Center"/>
        </SplitView.Content>
    </SplitView>
</Grid>

下一页将加载到 SplitView 的内容中。

<Page>
  <Grid>

  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="*"/>
    <ColumnDefinition Width="200"/>
  </Grid.ColumnDefinitions>

    <ScrollViewer Background="Cyan" Grid.Column="1" VerticalScrollBarVisibility="Auto">
      <RelativePanel Padding="20" MaxHeight="700" VerticalAlignment="Top">
        <A lot of Components: TextBlocks, TextBoxes, RadioButtons, ... />
      </RelativePanel>
    </ScrollViewer>
  </Grid>
</Page>

ScrollViewer 应该作为 window 右侧的工具栏。但是当我调整 window 大小时,垂直滚动不起作用。

全屏:

调整大小:

问题是因为您的 SplitView 在 <RowDefinition Height="Auto"/> 所在的行中。这使得 SplitView 高于屏幕,因此不会滚动。
对此行使用 <RowDefinition Height="*"/> 使其与屏幕一样高。

<Grid.RowDefinitions>
        <RowDefinition Height="50"/>
        <RowDefinition Height="*"/>
</Grid.RowDefinitions>

<SplitView Grid.Row="1">
    ....
</SpitView>