显示动画的已用时间 [英] Displaying Elapsed Time for an Animation

查看:80
本文介绍了显示动画的已用时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个2分钟的动画,并希望在屏幕上显示正在运行的计时器/计数器,以便用户知道动画播放时的位置(例如,00:01:02:00,00:02) / 02:00等。)有没有人知道如何在动画播放时动态更新文本
显示?感谢您的任何指示!

I've created a 2 minute animation and want to display a running timer/counter on-screen so that the user knows where they are as the animation plays (e.g., 00:01/02:00, 00:02/02:00, etc.) Does anyone know how I can dynamically update the text display as the animation plays? Thanks for any pointers!

推荐答案

你好,

我没有开箱即用的解决方案,因为动画系统不会为你提供这些属性。

I dont have a solution for you straight out of the box, because the animation system doesnt give you those properties to view.

您可以看到的是以下两个链接:

What you can have a look at are the following two links:

http://msdn.microsoft.com/en-us/library/aa970564(VS .85).aspx #useperframecallback

http://msdn.microsoft.com/en-us/library/system.windows.media.animation.animationtimeline(v = VS.85)的.aspx

具体看看每帧回调,如果你真的需要精确度,你可以创建一个自定义时钟或动画时间轴对象来公开这些信息。如果您不需要精确度,最简单的解决方案是在代码中创建DispatcherTimer
对象并在启动动画的同时启动该计时器,然后在计时器的每个刻度上启动,更新您的UI。

Specifically have a look at per frame call backs and if you really need the accuracy, you could create a custom clock or animation timeline object that exposes that information. If you dont need dead on accuracy, the simplest solution is to create a DispatcherTimer object in code and start that timer at the same time as starting your animation and then on each tick of the timer, update your UI.

我敢打赌,这不是你正在寻找的答案,但我担心的几乎就是它 - 简短的回答是你需要弄脏一些代码来实现这一点。

I bet that isnt the answer you are looking for but I am afraid that is pretty much it - the short answer is that you need to get dirty in some code to achieve this.

干杯


这篇关于显示动画的已用时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆