如何在 Windows Phone 7 中使用图像创建无限轮播效果

发布于 2024-10-21 06:56:08 字数 604 浏览 1 评论 0原文

在我的 Windows Phone 7 应用程序中,我有一个对象列表,其中每个对象都有关联的图像(总共大约 40 个)。我的主页上有一张图像,以及一个按钮,用户可以单击该按钮来随机选择其中一个对象,然后更改图像以匹配随机选择的对象。

对于动画效果,我想要一个水平的“老虎机”效果,其中原件的另外两张图片(左侧和右侧)将出现在屏幕上,然后所有这些图片都会快速向左移动。当每个图像离开屏幕时,它应该重新出现在右侧(就在屏幕之外),并加载不同的图片,并且这一切都应该持续一段设定的时间(在放慢速度并停止到所选图像之前)。

我做了一些研究,发现 PathListBox 对于这种动画/旋转来说是完美的,但不幸的是它只在 Silverlight 4 中,而 Windows Phone 7 正在运行 Silverlight 3。另一种方法是使用水平列表框并重新-排序项目将它们移动到最后......但我不太确定如何在动画中做到这一点。

最糟糕的是,实现它的真正可怕的方法是使用 DoubleAnimation,每个图像都有数十个未对齐的关键帧,并计算每个图像离开屏幕的时间,然后在其后设置一个离散的关键帧以将图像弹出屏幕右侧。这将是完全乏味的并且涉及大量的硬编码,并且几乎不可能应用缓动函数(加速/减速)。这样做的最佳方法是什么?

谢谢!!

In my Windows Phone 7 application, I have a list of objects with images associated with each one (about 40 total). I have one of the images on my main page, and a button which the user can click to randomly choose one of the objects, and then change the image to match the randomly chosen object.

For the animation effect, I would like to have a horizontal "slot machine" effect, where two other pictures (to the left and right) of the original will appear on the screen, and then all of them will move very quickly to the left. As each one leaves the screen, it should reappear to the right (just off the screen) with a different picture loaded, and this should all continue for a set duration of time (before slowing down and stopping to the chosen image).

I did some research and found out that the PathListBox would be perfect for this kind of animation/rotation, but unfortunately it is only in Silverlight 4, and Windows Phone 7 is running Silverlight 3. Another way would be to use a horizontal listbox and re-order the items to move them to the end... but I'm not really sure how to do that in an animation.

Worst comes to worst, the really terrible way to implement it is to use a DoubleAnimation with dozens of mis-aligned keyframes for each image, and calculate when each image leaves the screen, then set a discrete keyframe right after that to pop the image on the right of the screen. This would be completely tedious and involve a ton of hard-coding, and would be near impossible to apply an easing function to (speed up/slow down). What is the best way of doing this?

Thanks!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

荒岛晴空 2024-10-28 06:56:08

我认为通过对模板进行一些处理,您可以使用 LoopingSelector 来实现您想要的内容。 WindowsPhoneGeek.com 上有一系列很棒的系列帖子 对此进行了讨论。

基本原理是相同的,因为您有一个循环数据集,这只是更改方向以使其水平滚动而不是垂直滚动的情况。

I think with some juggling with the templates you could use the LoopingSelector to implement what your looking for. There's a great series of posts on WindowsPhoneGeek.com that discusses it.

The underlying prinicple is the same in that you have a looping data set, it's just a case of changing the orientation so that it scrolls horizontally instead of vertically.

娇俏 2024-10-28 06:56:08

您正在寻找的效果几乎可以使用枢轴控件来实现 - 无尽枢轴控件

或者还有一个一些开源实现有点像苹果的 Coverflow - 例如 http://sigurdsnorteland.wordpress.com/2010/09/19/wp7-samples-upgraded-to-rtm/

The effect you are looking for could almost be achieved using a pivot control - Endless Pivot Control

Alternatively there are a few open source implementations of things a bit like Apple's Coverflow - e.g. http://sigurdsnorteland.wordpress.com/2010/09/19/wp7-samples-upgraded-to-rtm/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文