在WP7上使用scrollviewer自动SnapBack

时间:2012-03-21 05:34:31

标签: c# windows-phone-7

大家好我的滚动问题,总是快速回复有人帮我找到错误:)谢谢!  更新了,仍然无法正常工作

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Height="954" Background="White">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" MinHeight="45"/>
        <RowDefinition/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->

    <!--ContentPanel - place additional content here-->
    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Margin="12,17,0,28" />
    <!--ContentPanel - place additional content here-->
    <ScrollViewer HorizontalAlignment="Left" x:Name="scrollViewer1" VerticalAlignment="Stretch" Width="465" Margin="-9,0,0,0">
        <Grid x:Name="ContentPanel" Margin="12,8,12,-226" Grid.RowSpan="2" >

            <Grid Height="986" Margin="6,2,-37,730">
                <Grid.RowDefinitions>
                    <RowDefinition Height="832*" />
                    <RowDefinition Height="154*" />
                </Grid.RowDefinitions>
                <StackPanel x:Name="stackPanel1" Margin="16,116,227,0" d:LayoutOverrides="HorizontalAlignment" Grid.RowSpan="2"></StackPanel>
                <StackPanel x:Name="stackPanel2" Margin="0,173,9,-11" HorizontalAlignment="Right" Width="207" Grid.RowSpan="2"></StackPanel>
                <Rectangle Height="50" HorizontalAlignment="Left" Margin="-26,33,0,0" Name="rectangle1" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="359" Fill="#FFFF57CB" />
                <TextBlock Height="51" HorizontalAlignment="Left" Margin="24,33,0,0" Name="textBlock1" Text="Case Taking" VerticalAlignment="Top" Width="311" FontWeight="SemiBold" FontSize="32" />
            </Grid>

        </Grid>
    </ScrollViewer>
</Grid>

1 个答案:

答案 0 :(得分:0)

从ScrollViewer中删除Height =“...”并将其更改为VerticalAlignment =“Stretch”

ScrollViewer将滚动它的内容。你正在做的是给ScrollViewer一个大尺寸(有高度),因此它认为它不需要滚动。