动画在Windows Phone 8.1中不起作用

时间:2014-05-09 17:10:05

标签: c# animation windows-phone windows-phone-8.1

我只想在Windows Phone 8.1应用程序中创建一个简单的动画

我正在考虑通过在大约300毫秒的时间段内更改6张图片来创建动画效果,最终会使用6-7张图像留下自定义动画。

但是下面代码的问题是,它不会产生闪烁效果,它只显示第一张图像,然后显示最后一张。

我尝试增加时间段,但仍然相同。

animationBg = new ObjectAnimationUsingKeyFrames();
storyboardBG = new Storyboard();
Storyboard.SetTarget(animationBg, imgMinuteBackground);
Storyboard.SetTargetProperty(animationBg, "Source");
storyboardBG.Children.Add(animationBg);
AddFrame(animationBg, "Images/clockbg2.png", 50);
AddFrame(animationBg, "Images/clockbg3.png", 100);
AddFrame(animationBg, "Images/clockbg4.png", 150);
AddFrame(animationBg, "Images/clockbg5.png", 200);
AddFrame(animationBg, "Images/clockbg6.png", 250);
AddFrame(animationBg, "Images/clockbg1.png", 300);
storyboardBG.Begin();


//AddFrame Function:
public void AddFrame( ObjectAnimationUsingKeyFrames animation, string strImagePath, int interval)
{
    var keyframe = new DiscreteObjectKeyFrame 
    {
         KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(interval)),
         Value = strImagePath
    };
    animation.KeyFrames.Add(keyframe);
}

我更改了"来源"到新的PropertyPath(" Source"),它适用于Windows Phone 7应用程序。

1 个答案:

答案 0 :(得分:0)

如MSDN教程所述,动画仅适用于Windows Phone 8.1 Silverlight应用程序。 http://msdn.microsoft.com/en-us/library/windows/apps/jj206955(v=vs.105).aspx#BKMK_Startingstoppingpausingandresuming

  

适用于:Windows Phone 8和Windows Phone Silverlight 8.1 | Windows Phone OS 7.1

它不适用于Windows phone 8.1 app