WPF,这个动画怎么实现?
Button的Width属性从当前值作3次增大动画,要求如下:1:每次动画,使Width在上一次动画的基础上增加20
2:每次动画执行2秒钟
3:每次动画开始前延迟1秒钟 --------------------编程问答-------------------- 有人知道吗?? --------------------编程问答-------------------- http://blog.csdn.net/tongben11/article/details/7462041
1.事件触发里面添加事件;
2.动画时间在代码中修改(TimeSpan.FromSeconds(1));
3.动画之前的延迟可以考虑使用Thread.Sleep(1000)或者添加一个Timer计时器;
--------------------编程问答-------------------- http://blog.csdn.net/tongben11/article/details/7462041 --------------------编程问答-------------------- 用Storyboard,怎么写? --------------------编程问答--------------------
--------------------编程问答--------------------
private void btnMain_Click(object sender, RoutedEventArgs e)
{
DoubleAnimation animation = new DoubleAnimation();
//设置动画的结束值
animation.To = this.btnMain.ActualWidth + 20;
//动画执行长度为2秒
animation.Duration = TimeSpan.FromSeconds(2);
//开始1秒后执行动画
animation.BeginTime = TimeSpan.FromSeconds(1);
//累计动画的变化值
animation.IsCumulative = true;
//动画重复播放3次
animation.RepeatBehavior = new RepeatBehavior(3);
//启动动画
this.btnMain.BeginAnimation(Button.WidthProperty, animation);
}
重复3次,要求每次都延迟1秒,不是只有第一次才延迟。你这段只有第一次才延迟 --------------------编程问答-------------------- 有人知道吗,用Storyboard怎么写? --------------------编程问答-------------------- 有人知道吗,用Storyboard怎么写? --------------------编程问答-------------------- 看起来好厉害的样子。 --------------------编程问答-------------------- 不觉明历??? --------------------编程问答-------------------- 有人知道吗,用Storyboard怎么写? --------------------编程问答-------------------- 有人知道吗,用Storyboard怎么写? --------------------编程问答-------------------- 有人知道吗,用Storyboard怎么写? --------------------编程问答-------------------- 使用Blend for Visual Studio 。 --------------------编程问答-------------------- wpf好强大啊 --------------------编程问答-------------------- 有人知道吗,用Storyboard怎么写? --------------------编程问答-------------------- private void btnMain_Click(object sender, RoutedEventArgs e)
{
for(int i=0;i<3;i++){
DoubleAnimation animation = new DoubleAnimation();
//设置动画的结束值
animation.To = this.btnMain.ActualWidth + 20;
//动画执行长度为2秒
animation.Duration = TimeSpan.FromSeconds(2);
//开始1秒后执行动画
animation.BeginTime = TimeSpan.FromSeconds(1);
//累计动画的变化值
animation.IsCumulative = true;
//启动动画
this.btnMain.BeginAnimation(Button.WidthProperty, animation);
}
} --------------------编程问答-------------------- 稍微改下差不多了 --------------------编程问答-------------------- 要么加个Thread。Sleep(1000)
睡眠1秒
private void btnMain_Click(object sender, RoutedEventArgs e)
{
for(int i=0;i<3;i++){
DoubleAnimation animation = new DoubleAnimation();
//设置动画的结束值
animation.To = this.btnMain.ActualWidth + 20;
//动画执行长度为2秒
animation.Duration = TimeSpan.FromSeconds(2);
//开始1秒后执行动画
animation.BeginTime = TimeSpan.FromSeconds(1);
//启动动画
this.btnMain.BeginAnimation(Button.WidthProperty, animation);
Thread。Sleep(1000)
}
} --------------------编程问答-------------------- 没效果哦........... --------------------编程问答-------------------- 有人知道吗,用Storyboard怎么写? --------------------编程问答-------------------- 有人知道吗,用Storyboard怎么写? --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 有人知道吗,用Storyboard怎么写? --------------------编程问答-------------------- 有人知道吗,用Storyboard怎么写? --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 有人知道吗,用Storyboard怎么写? --------------------编程问答-------------------- http://blog.sina.com.cn/s/blog_6f99d8ea0100v0av.html
补充:.NET技术 , C#