简体   繁体   English

Windows Phone 8.1 Scrollviewer

[英]Windows Phone 8.1 Scrollviewer

I am building an app for Windows Phone 8.1 and my scroll viewer keeps going back to the top after you release scrolling. 我正在为Windows Phone 8.1构建一个应用程序,并且在您松开滚动键后,滚动查看器会一直返回顶部。 Its like I drag it down and when I release it, it snaps back to top. 就像我将其向下拖动并释放时一样,它会弹回到顶部。

<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>

ScrollViewer is designed to handle content that is bigger than the surrounding container. ScrollViewer旨在处理大于周围容器的内容。 So normally your ScrollViewer's height is smaller than its content's. 因此,通常ScrollViewer的高度小于其内容的高度。

Just adjust the height of your ScrollViewer and content, eg: 只需调整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>

In your case the Grid is much smaller than the ScrollViewer so I'd expect the behaviour you are describing. 在您的情况下,Grid比ScrollViewer小得多,因此我希望您所描述的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM