带有固定标题的UWP垂直滚动条

Ste*_*yer 3 uwp

在UWP中,我希望有一个固定的标题行,其中包含我的应用程序顶部的一些按钮.屏幕的其余部分应垂直滚动(如固定导航).

到目前为止这是我的代码:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <StackPanel>
        <RelativePanel>
            <Button x:Name="btntest" Content="fixed button"/>
        </RelativePanel>
        <StackPanel>
            <ScrollViewer x:Name="MyScrollView" VerticalScrollBarVisibility="Visible">
                <StackPanel Padding="0,30,0,0">
                   [...my Content...]
                </StackPanel>
            </ScrollViewer>
        </StackPanel>
    </StackPanel>
</Grid>
Run Code Online (Sandbox Code Playgroud)

它没有做我想要的,因为显示了滚动条,但内容(高于屏幕)无法滚动.

我怎样才能实现目标 - 如何安排面板(Stack,Relative?)和ScrollViewer?

Rom*_*asz 6

如果我理解你是正确的并且你想在滚动查看器上方有一个固定的标题,那么你应该能够通过使用垂直StackPanel或使用具有合适行的网格来实现这一点(一切都取决于你的需要).样品:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Button Grid.Row="0" x:Name="btntest" Content="fixed button"/>
    <ScrollViewer Grid.Row="1" x:Name="MyScrollView" VerticalScrollBarVisibility="Visible">
        <StackPanel Padding="0,30,0,0">
            [...my Content...]
        </StackPanel>
    </ScrollViewer>
</Grid>
Run Code Online (Sandbox Code Playgroud)