wp7 -动画
<Rectangle Width="100" Height="100" HorizontalAlignment="Left" VerticalAlignment="Top" Fill="Red" Name="darkMoon"/>
DoubleAnimationUsingKeyFrames doublea = new DoubleAnimationUsingKeyFrames()
{
BeginTime = new TimeSpan(0, 0, 0, 2),
SpeedRatio=1,
Duration = new Duration(TimeSpan.FromSeconds(1)),
AutoReverse = false,
RepeatBehavior = new RepeatBehavior(20),
FillBehavior = FillBehavior.HoldEnd
};
EasingDoubleKeyFrame key1 = new EasingDoubleKeyFrame()
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)),
Value = 0
};
EasingDoubleKeyFrame key2 = new EasingDoubleKeyFrame()
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1)),
Value = 100
};
EasingDoubleKeyFrame key3 = new EasingDoubleKeyFrame()
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2)),
Value = 200
};
EasingDoubleKeyFrame key4 = new EasingDoubleKeyFrame()
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(3)),
Value = 300
};
doublea.KeyFrames.Add(key1);
doublea.KeyFrames.Add(key2);
doublea.KeyFrames.Add(key3);
doublea.KeyFrames.Add(key4);
Storyboard storyboard2 = new Storyboard();
Storyboard.SetTarget(doublea, darkMoon);
Storyboard.SetTargetProperty(doublea, new PropertyPath(WidthProperty));
storyboard2.Children.Add(doublea);
storyboard2.Begin();
////////////////////////////////////////////////////////////////////////////////////////////////////////
DoubleAnimation doublea = new DoubleAnimation()
{
BeginTime = new TimeSpan(0, 0, 0, 2),
From = 200,
To = 300,
Duration = new Duration(TimeSpan.FromSeconds(1)),
AutoReverse = false,
RepeatBehavior = new RepeatBehavior(20),
FillBehavior = FillBehavior.HoldEnd
};
Storyboard storyboard2 = new Storyboard();
Storyboard.SetTarget(doublea, darkMoon);
Storyboard.SetTargetProperty(doublea, new PropertyPath(WidthProperty));
storyboard2.Children.Add(doublea);
storyboard2.Begin();