Windows phone 8 使用情节提要Windows phone 8制作动画

Windows phone 8 使用情节提要Windows phone 8制作动画,windows-phone-8,Windows Phone 8,我正在使用Windows Phone 8应用程序。我使用故事板来制作一系列图像的动画。它工作正常,但我想在动画完成前一秒钟调用一个特定的方法。我正在使用这个代码:有没有一种方法可以实现我想要的 var storyboard12 = new Storyboard { // RepeatBehavior = RepeatBehavior.Forever }; var animation = new ObjectAnimation

我正在使用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();
    }
var故事板12=新故事板
{
//RepeatBehavior=RepeatBehavior.永远
};
var animation=使用关键帧()的新对象动画;
故事板.SetTarget(动画、动画图像);
Storyboard.SetTargetProperty(动画,新属性路径(“源”);
故事板12.儿童。添加(动画);

对于(int i=1;i您可以使用另一个故事板,它将更改控件的背景。这种方式更适合于性能原因。并且Dispatchermer Tick事件不会在设置的间隔后100%触发,它可能会在4.1之后触发,如果这对您很重要,则这是使用故事板更改ba的第二个原因ckground.

非常感谢您的回复,但问题是我们什么时候可以启动第二个故事板?我的问题是,当我添加故事板动画时,想在完成第一个故事板动画前一秒钟调用另一个具有图像序列的故事板动画。您可以计算第一个故事板的持续时间。例如,如果第一个故事板的持续时间是4秒,然后您需要将第二个故事板的开始时间推迟3秒。请检查故事板类的BeginTime属性。