使对象“悸动”/成长和收缩

时间:2012-06-04 01:39:29

标签: wpf pixelsense

WPF很新,但我已经制作了一款Surface应用程序,以吸引人们的关注。

http://www.diaryofaninja.com/blog/2012/06/03/building-an-image-and-video-viewer-for-microsoft-surface-20-in-no-time-at-all

我想做的是,如果人们有一段时间没有触摸屏幕(我已经用计时器录制了这个),我想让我的应用程序中的每个对象“Throb”一个一个引起人们注意的。

我会使用转换或故事板吗?

1 个答案:

答案 0 :(得分:2)

我最终在计时器上调用了以下方法:

void RunScaleAnimation(FrameworkElement e)
{

var storyboard = new Storyboard();
var easeOut = new BackEase { EasingMode = EasingMode.EaseOut, Amplitude = 0.3 };

double startHeight = e.ActualHeight;
double startWidth = e.ActualWidth;

var growAnimationHOut = new DoubleAnimation(startHeight, startHeight * 1.05,
                                            TimeSpan.FromMilliseconds(100)) { AutoReverse = true };

var growAnimationWOut = new DoubleAnimation(startWidth, startWidth * 1.05,
                                            TimeSpan.FromMilliseconds(100)) { AutoReverse = true };

growAnimationHOut.EasingFunction = easeOut;
growAnimationWOut.EasingFunction = easeOut;

storyboard.Children.Add(growAnimationHOut);
storyboard.Children.Add(growAnimationWOut);

Storyboard.SetTargetProperty(growAnimationWOut, new PropertyPath(FrameworkElement.WidthProperty));
Storyboard.SetTargetProperty(growAnimationHOut, new PropertyPath(FrameworkElement.HeightProperty));

e.BeginStoryboard(storyboard);
}