如何在动画开始时更改动画的端点 [英] How to change the endpoint for animation when the animation started

查看:69
本文介绍了如何在动画开始时更改动画的端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用WPF创建用户控件但我不能

当更改表单大小时计算结束点

运行 - 时间动画



http://www.mediafire。 com / view / 79d9gacbbk716wp / 4.png [ ^ ]





hi
I create user control with WPF but I can't
Calculation end point when the change form size the
Run-time animations

http://www.mediafire.com/view/79d9gacbbk716wp/4.png[^]


//Set Location
ContentControl.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
Canvas.SetLeft(ContentControl, 3);

//Define Strat And End Animation
myDoubleAnimation1.From = 0 ;
myDoubleAnimation1.To = this.ActualWidth ;
myDoubleAnimation1.Duration =TimeSpan.FromSeconds(1);
sb.Duration =TimeSpan.FromSeconds(1);

Storyboard.SetTarget(myDoubleAnimation1, ContentControl);
Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath("(FrameworkElement.RenderTransform).(TranslateTransform.X)"));
 

sb.Children.Add(myDoubleAnimation1);
//Event For Finish the Animation
sb.Completed += _Completeds;

// Begin the animation.
sb.Begin();

推荐答案

我认为你不能用正在运行的动画改变这些属性。



您可能会尝试停止动画,将属性设置为新值,然后在
I don't think you can change these properties with a running animation.

You might try to stop the animation, set the properties to the new values and start again in the
private void Main_SizeChanged(object sender, SizeChangedEventArgs e)



窗口事件背后的代码。


code behind event of your window.


这篇关于如何在动画开始时更改动画的端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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