ScrollViewer在发布时向后滚动

时间:2011-11-30 13:06:10

标签: silverlight xaml windows-phone-7 itemscontrol scrollviewer

当我点击并按住并移动我的列表时,它会移动,但是当我不再按住时,它会平滑地滚动回到列表的开头。我该如何预防?

我也尝试将整个ItemsControl放在ScrollViewer中 - 行为相同。

没有ScrollViewer ItemsControl根本不滚动。

我将断点设置为ItemsPresenter,ItemsControl和ScrollViewer的ManipulationCompleted - 在所有这些中,滚动显示在我离开它的正确位置,但之后它会向后滚动。

这是我的xaml标记:

<Grid x:Name="LayoutRoot">
    <ItemsControl Name="lbDeployments" 
                    ItemsSource="{Binding Path=Deployments}"
                    ItemTemplate="{StaticResource DeploymentItem}" >
        <ItemsControl.Template>
            <ControlTemplate TargetType="ItemsControl">
                <Grid>
                    <ScrollViewer>                    
                        <ItemsPresenter />
                    </ScrollViewer>
                </Grid>
            </ControlTemplate>
        </ItemsControl.Template>
    </ItemsControl>

</Grid>

请帮忙

2 个答案:

答案 0 :(得分:1)

问题是ScrollViewer需要一个固定大小的容器才能知道它实际上可以滚动。

您需要设置ScrollViewer的高度或包含它的网格,以使scrollign正常工作。

没有这样做,scrollviewer认为它可以占用尽可能多的空间。在这种情况下,它不需要滚动,直接操作内容时看到的内容实际上并不是滚动,只是将内容移动到可滚动区域。

答案 1 :(得分:1)

尝试添加RowDefinitions

<Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
    </Grid>

    ... 
</Grid>
相关问题