Windows Phone App滚动到顶部

时间:2013-05-28 17:36:40

标签: xaml windows-phone-8 scrollviewer

然后我点击文本框碰巧滚动屏幕键盘没有关闭此文本框。如果此TextBox移到上面,我如何自动滚动页面?我尝试使用ScrollViewer,并使用他的方法InvalidateScrollInfo()Scroll.UpdateLayout()但页面不移动。来自我的页面的这个xaml:

<ScrollViewer x:Name="Scroll">
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
            <TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Canvas>
                <TextBox x:Name="SearchTB" Width="200" Height="72" TextChanged="TextBox_OnTextChanged" Canvas.Left="112" Canvas.Top="297"/>
            </Canvas>
        </Grid>

    </Grid>
</ScrollViewer>

1 个答案:

答案 0 :(得分:0)

您应该在父ScrollViewer上调用ScrollToVerticalOffset,参数为0以滚动到顶部。