我正在开发一个 Windows Phone 8 应用程序。我正在使用情节提要为一系列图像制作动画。它工作正常,但我想在动画完成前一秒调用特定方法。我正在使用这段代码:有没有办法做我想做的事?
var storyboard12 = new Storyboard
{
// RepeatBehavior = RepeatBehavior.Forever
};
var animation = new ObjectAnimationUsingKeyFrames();
Storyboard.SetTarget(animation, animationImage);
Storyboard.SetTargetProperty(animation, new PropertyPath("Source"));
storyboard12.Children.Add(animation);
for (int i = 1; i <=16; i++)
{
var keyframe = new DiscreteObjectKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(300*i)),
Value = String.Format("/Images+Audio/images/animation images/2_Driving-a-car/Drive_background3 ({0}).png", i)
};
animation.KeyFrames.Add(keyframe);
}
DispatcherTimer timer11 = new DispatcherTimer();
timer11.Interval = TimeSpan.FromSeconds(4.1);
timer11.Tick += timer11_Tick;
timer11.Start();
storyboard12.Begin();
storyboard12.Completed += storyboard12_Completed;
}
void timer11_Tick(object sender, EventArgs e)
{
var timer = (DispatcherTimer)sender;
timer.Stop();
changeBackgroundImage3();
}