【发布时间】:2012-05-28 20:58:46
【问题描述】:
我正在尝试创建一个动画,当用户滚动“FrontScroll”时,应用程序会自动以相同的速度滚动相同大小的“BackgroundScroll”到相同的偏移量。在前面和背景滚动之间分层的是一个我想保持静止的图像。中间的图像只占屏幕的 1/4,其余的图像在 png 中是透明的。我正在尝试创建当用户滚动时其他图像逐渐出现在静态图像上方和后面的效果。
目前我有一个关于 ManipulationCompleted 的事件,它可以工作,但是它会产生非常“抖动”的效果,因为在用户从屏幕上抬起手指之前,背景滚动不会滚动到某个位置。我想让动画即时,无论操作是否完成,从而使 2 个 ScrollViewer 保持完美同步。同样目前,当用户“轻拂” ScrollViewer 以移动更远的距离时,ManipulationCompleted 事件不会触发,因此 2 个 ScrollViewer 变得不同步。我也尝试过 MouseWheel、MouseLeave、MouseMove 事件,但都没有得到我想要的效果。
有谁知道我正在尝试使用 Windows Phone 7.5 中的当前 API 做的事情是否可行,如果可以,任何关于我如何做到这一点的指针将不胜感激?
我当前的 XAML 和 CodeBehind 事件如下。
<ScrollViewer HorizontalAlignment="Center" Margin="0,0,0,0" Name="backgroundScroll" VerticalAlignment="Top" Background="Transparent" MaxHeight="Infinity">
<Image HorizontalAlignment="Center" Height="2000" Stretch="Fill" Source="background@2x.png" />
</ScrollViewer>
<Image Source="MiddleStatic@2x.png" HorizontalAlignment="Center" Name="MiddleStatic" Stretch="Fill" VerticalAlignment="Top" Margin="-1,-1,0,0" />
<ScrollViewer HorizontalAlignment="Center" Name="FrontScroll" VerticalAlignment="Top" MaxHeight="Infinity" MinHeight="0" ManipulationCompleted="FrontScroll_ManipulationCompleted">
<StackPanel Background="#00000000">
<Image Height="2000" Source="FrontScrollImage@2x.png" HorizontalAlignment="Center" Name="FrontScroll" Stretch="Fill" />
</StackPanel>
</ScrollViewer>
</Grid>
private void FrontScroll_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
{
backgroundScroll.ScrollToVerticalOffset(((ScrollViewer)sender).VerticalOffset);
}
【问题讨论】:
-
您能在视频/应用程序中展示这种行为的示例吗?我不明白你在找什么。
标签: c# silverlight windows-phone-7 windows-phone-7.1