【问题标题】:UWP Vertical Scrollbar with fixed header带有固定标题的 UWP 垂直滚动条
【发布时间】:2016-06-03 18:54:25
【问题描述】:

在 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>

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

我怎样才能实现我的目标 - 我必须如何安排面板(堆栈、相对?)和 ScrollViewer?

【问题讨论】:

    标签: uwp


    【解决方案1】:

    如果我的理解是正确的,并且您希望在滚动查看器上方有一个固定标题,那么您应该能够通过使用垂直 StackPanel 或使用 Grid 来实现这一点合适的行(一切取决于您的需要)。示例:

    <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>
    

    【讨论】:

    • 谢谢 Romasz - 这正是我想要的,我在上面的代码中看到了我的错误 - 我级联太多了:/
    猜你喜欢
    • 2019-08-11
    • 1970-01-01
    • 2019-09-26
    • 1970-01-01
    • 2016-10-11
    • 1970-01-01
    • 2022-10-20
    • 2011-02-07
    • 1970-01-01
    相关资源
    最近更新 更多