2012-06-04 44 views
0

對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

我想做些什麼,是如果人們都沒有碰過了,而屏幕(我已經有計時器記錄本),我想讓每個對象在我應用程序「悸動」逐一引起人們的關注。

我會使用轉換還是故事板?

+0

你將有一個故事板改變一個ScaleTransform值。你只需要使用Storyboard的值來使它跳動(AccelerationRatio,DecelerationRatio)。 –

+1

嗯... downvotes? – Doug

回答

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); 
}