向下滚动后,Scrollviewer会反弹回来。 - Windows Phone

时间:2014-03-17 03:21:05

标签: wpf xaml windows-phone-7 windows-phone-8 scroll

我正在尝试从Windows手机查看我的数据。数据量将取决于该特定日期的数据量。例如1 / March / 1010有10个信息,我应该可以向下滚动查看其他信息。当我滚动时,在我从屏幕上松开手指后,我反弹了。我在这里做错了什么下面是我的XAML代码:

<!--Pivot Control-->
    <phone:Pivot Title="MY APPLICATION">
        <!--Pivot item one-->
        <phone:PivotItem Header="today">
            <StackPanel>
                <toolkit:DatePicker x:Name="NowDate"  
                                    HorizontalAlignment="Left" 
                                    Width="456"
                                    Background="DarkBlue" 
                                    ValueStringFormat="{}{0:D}"
                                    Foreground="White"
                                    BorderBrush="DarkBlue" 
                                    />
                <TextBlock Name="NoData"
                           HorizontalAlignment="Left"
                           Text="No Information Available" 
                           Margin="18,0,0,0" 
                           Visibility="Collapsed"
                           />

                <!--Double line list with text wrapping-->
                <ScrollViewer VerticalScrollBarVisibility="Visible">
                    <phone:LongListSelector x:Name="MLongListSelector" 
                                            Margin="0,0,-12,0" 
                                            SelectionChanged="MainLongListSelector_SelectionChanged">
                        <phone:LongListSelector.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="0,0,0,17">
                                    <TextBlock Text="{Binding Title}" 
                                               TextWrapping="Wrap" 
                                               Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                                    <TextBlock Text="{Binding Description}"
                                               Name="Description"
                                               TextTrimming="WordEllipsis" 
                                               MaxHeight="84"
                                               TextWrapping="Wrap" 
                                               Style="{StaticResource PhoneTextSmallStyle}"/>
                                </StackPanel>
                            </DataTemplate>
                        </phone:LongListSelector.ItemTemplate>
                    </phone:LongListSelector>
                </ScrollViewer>
            </StackPanel>
        </phone:PivotItem>

1 个答案:

答案 0 :(得分:1)

您必须将ScrollViewer的高度设置为小于父控件的高度(在您的情况下为StackPanel)。如果ScrollViewer比它的孩子大,那么孩子将总是弹回原来的位置。