在SplitView.Content内部的UWP ScrollViewer不滚动

时间:2016-11-17 01:00:53

标签: xaml uwp scrollviewer

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

的MainPage:

<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应该在窗口右侧作为工具栏使用。但是当我调整窗口大小时,垂直滚动不起作用。

全屏: Page in full screen

调整大小: Page resized

1 个答案:

答案 0 :(得分:1)

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

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

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