Windows Phone 8.1 Scrollviewer

时间:2014-10-05 20:24:48

标签: c# xaml windows-phone-8.1 scrollviewer

我正在构建一个适用于Windows Phone 8.1的应用程序,我的滚动查看器会在您发布滚动后继续回到顶部。它就像我拖下来一样,当我释放它时,它会快速回到顶部。

<ScrollViewer Margin="10,0,10,-1024" Height="1124" VerticalAlignment="Top" 
  VerticalScrollBarVisibility="Visible" VerticalScrollMode="Enabled"
  AllowDrop="False" BringIntoViewOnFocusChange="True"
  HorizontalScrollMode="Disabled" IsHoldingEnabled="True" >

    <Grid Grid.Row="1" x:Name="ContentRoot" Height="468" Width="386" >

        <TextBlock HorizontalAlignment="Left" Margin="64,326,0,0"
          TextWrapping="Wrap" VerticalAlignment="Top" Foreground="White"
          FontSize="16" Width="307" Height="68" >

            <Run Foreground="#FFFF6767" Text="Single Phase "/>
            <Run Foreground="#FFFF6767" Text="Amperes "/>
            <Run Text="= "/>
            <Run Text="(746 x Horsepower) / (Volts x Efficiency x Power Factor"/>
            <Run Text=")"/>

        </TextBlock>

    </Grid>

</ScrollViewer>

1 个答案:

答案 0 :(得分:6)

ScrollViewer旨在处理比周围容器更大的内容。所以通常你的ScrollViewer的高度小于它的内容。

只需调整ScrollViewer和内容的高度,例如:

<ScrollViewer Height="500" VerticalAlignment="Top" VerticalScrollBarVisibility="Visible" VerticalScrollMode="Enabled" AllowDrop="False" BringIntoViewOnFocusChange="True" HorizontalScrollMode="Disabled" IsHoldingEnabled="True" >
<Grid Grid.Row="1" x:Name="ContentRoot" Height="800" Width="386" >
[..]

</Grid>
</ScrollViewer>

在你的情况下,Grid比ScrollViewer小得多,所以我期待你所描述的行为。