在对时间轴进行动画处理时获取对象位置 [英] Get object position while animationing timeline

查看:116
本文介绍了在对时间轴进行动画处理时获取对象位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用blend创建状态,我使用时间轴将对象从一个地方移动到另一个地方
问题是..时间轴运行时我无法获取对象的位置,结果冻结
事件,尽管我使用计时器来跟踪位置
这是我的代码.

i''m use blend to create States and I use Timeline to move object from place to place
problem is.. I can''t get object''s position while timeline is running, Result is freezing
event though i''m use timer to track position
Here is my code.

private void b1_Click(object sender, RoutedEventArgs e)
        {
            state1.Storyboard.Begin();  //play timeline in states
        }

void updatePos_Tick(object sender, object e)
        {
            textblock.text = Canvas.getLeft(myobject);
        }


在屏幕上,"myobject"正在移动,但是"textblock"没有告诉我真正的位置,请帮忙.谢谢.


On the screen, "myobject" is moving but "textblock" doesn''t tell me where really are, please help, thanks.

推荐答案

我找到了答案今天是我自己(花了3个月的时间哈哈)
只需使用计时器刻度线...
[C#]
I have found answer by myself today (took 3 months haha)
Just use timer tick This...
[C#]
textblock.Text = myMovingCanvas.RenderTransform.GetValue(CompositeTransform.TranslateXProperty).ToString(); 



因为情节提要的目标使用此属性...
[xaml]



Because storyboard''s target use this properties...
[xaml]

<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="myMovingCanvas"


这篇关于在对时间轴进行动画处理时获取对象位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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