UWP ScrollViewer 和 StackPanels 无法正常工作

UWP ScrollViewer and StackPanels don't work properly

UWP ScrollViewer 元素在我的 StackPanel 中根本不滚动。我试过 Grids 和行定义,但也没有用。这是我目前的 XAML.

GIF showing scrolling not working properly

<Page
    x:Class="Thunderstorm.Pages.Home"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Thunderstorm.Pages"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <ScrollViewer VerticalScrollBarVisibility="Auto" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <StackPanel>
            <StackPanel x:Name="Weather"
                        Background="LightBlue"
                        Height="500"
                        MaxHeight="750"
                        VerticalAlignment="Top" 
                        Padding="10,0,0,0">
                <TextBlock Text="25℉" Style="{ThemeResource HeaderTextBlockStyle}" FontSize="85" Margin="25,25,0,0" MaxWidth="500" HorizontalAlignment="Left"/>
            </StackPanel>
            <StackPanel>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
                <TextBlock Text="Scroll test string to overflow"/>
            </StackPanel>
        </StackPanel>
    </ScrollViewer>
</Page>

(如果这是一个愚蠢的问题,我深表歉意 - 我是 UWP 开发的新手,也无视我在 TextBlock 上明确定义的字体大小)

我无法重现您的问题,即使我将页面置于 GIF 示例中的导航视图中也是如此。

我怀疑有一个 parent 元素允许内容增长到任何可能的大小。您可以在空白项目中自行测试。当您将 post 编辑的 XAML 放入空白项目时,滚动将按预期工作。

当你把 ScrollViewerRowHeight="Auto" 放在 StackPanelGrid 中时,它不会滚动,因为 parent "offered" 它需要任何 space。 GIF 实际上证明了这一点——看到滚动查看器的底部被裁剪了(向下的箭头不可见)——这是因为层次结构上的某些东西让它增长到它想要的任何大小。

ScrollViewer有没有parent?如果没有,如何在 NavigationView 中显示页面?如果我的建议没有帮助,请 post NavigationView XAML。

我调用导航的框架位于堆栈面板内,直到现在我才注意到它。我删除了堆栈面板并使用我的原始代码进行滚动。