包含网格的ScrollViewer快速回到顶部

时间:2013-11-07 00:49:09

标签: c# xaml windows-phone-8

我正在使用ScrollViewer来启用它包含的Grid可滚动。但是,当我向下滚动后松开时,它会自动滚动回到网格的顶部。

<ScrollViewer>

    <Grid ShowGridLines="false" MinHeight="700">
        <Grid.RowDefinitions>
            <RowDefinition Height="1" /> 
            <RowDefinition Height="{Binding Pivot1Rows[0].RowHeight}" />
            <RowDefinition Height="1" />
            <RowDefinition Height="{Binding Pivot1Rows[1].RowHeight}" /> 
            <RowDefinition Height="1" />
            <RowDefinition Height="{Binding Pivot1Rows[2].RowHeight}" />
            <RowDefinition Height="1" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="2*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <!-- Stackpanels for each row/column combo here -->
     </Grid>

</ScrollViewer>

任何想法我需要添加/更改以确保即使在我放手之后,网格中的位置仍然保持不变?

1 个答案:

答案 0 :(得分:2)

您必须将ScrollViewer的高度设置为小于Grid的高度。如果ScrollViewer比它的孩子大,孩子将总是弹回原来的位置。