【问题标题】:ScrollViewer not scrolling in Windows Phone 8ScrollViewer 在 Windows Phone 8 中不滚动
【发布时间】:2014-04-08 08:27:25
【问题描述】:

看来 xaml 不是我的菜。标题说明了一切。

<phone:Panorama Title="MSFT Insider" Background="#FFD8D8D8" Foreground="Black" Style="{StaticResource PanoramaStyle1}">

            <!--Elemento Panorama uno-->
            <phone:PanoramaItem Header="Portada" FontSize="20">
                <StackPanel HorizontalAlignment="Left" Width="416">
                    <ScrollViewer Height="Auto" Width="416" HorizontalAlignment="Left" VerticalAlignment="Top" VerticalScrollBarVisibility="Auto">

                        <ListBox x:Name="frontpost_list" Width="416" Height="Auto" Margin="0,0,0,0" VerticalAlignment="Top" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                    <StackPanel HorizontalAlignment="Left" Height="Auto" VerticalAlignment="Top" Width="416">
                                        <Grid Width="415" Height="240">
                                            <Image Source="Assets/PanoramaBackground.png" Stretch="UniformToFill" Height="240" Width="415"/>
                                            <TextBlock VerticalAlignment="Bottom" FontSize="29.333" FontWeight="Bold" Margin="10,0,10,20" UseLayoutRounding="True" Padding="0" TextWrapping="Wrap" TextTrimming="WordEllipsis" Text="{Binding Title}" FontFamily="Arial" CharacterSpacing="1" Foreground="Black"/>
                                        </Grid>
                                    </StackPanel>
                                </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                    </ScrollViewer>
                </StackPanel>
                <!--Lista de una línea con ajuste automático de texto-->
            </phone:PanoramaItem>

屏幕自动回到之前的位置,滚动未完成。它只是向下移动,而不是像松紧带一样向后移动。

ScrollViewer 不滚动,ScrollViewer 内部的元素比包含 ScrollViewer 的 StackPanel 最长。当我尝试滚动时,它会弹跳。

谢谢。

【问题讨论】:

    标签: windows-phone-8 scrollviewer


    【解决方案1】:

    编辑了我的答案。在VS中尝试过这个并发现了错误。 ListBox 根本不需要 ScrollViewer 而你有 Height="Auto"。这意味着它将 ListBox 扩展到所需的高度,从而禁用它的可滚动性。而且您不需要在 DataTemplate 中同时使用 StackPanel 和 Grid。

    <phone:PanoramaItem Header="Portada" FontSize="20">
                <StackPanel HorizontalAlignment="Left" Width="416">
                        <ListBox x:Name="frontpost_list" Width="416" Height="400" Margin="0,0,0,0"> //Notice the height
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel HorizontalAlignment="Left" Height="Auto" VerticalAlignment="Top" Width="416">
                                        <Image Source="Assets/PanoramaBackground.png" Stretch="UniformToFill" Height="240" Width="415"/>
                                        <TextBlock VerticalAlignment="Bottom" FontSize="29.333" FontWeight="Bold" Margin="10,0,10,20" UseLayoutRounding="True" Padding="0" TextWrapping="Wrap" TextTrimming="WordEllipsis" Text="{Binding Title}" FontFamily="Arial" CharacterSpacing="1" Foreground="Black"/>
                                    </StackPanel>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                </StackPanel>
                <!--Lista de una línea con ajuste automático de texto-->
            </phone:PanoramaItem>
    

    【讨论】:

    • 你想滚动什么元素?
    • 列表框“frontpost_list”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多