Animation not working in Windows Phone 8.1

2020-04-21 07:47发布

I am just trying to create a simple animation in my Windows Phone 8.1 Application

I am thinking to create an animation effect by changing 6 images at some 300 milliseconds period, which ends up leaving a custom animation using 6-7 images.

but the problem with the below code is, it isn't creating a flicker effect, it just displays 1st image and then last one.

I tried increasing the time period, but still the same.

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

I changed the "Source" to new PropertyPath("Source") and it is working for Windows Phone 7 Applications.

1条回答
疯言疯语
2楼-- · 2020-04-21 08:07

As stated on MSDN tutorial, animation only available for Windows Phone 8.1 Silverlight app. http://msdn.microsoft.com/en-us/library/windows/apps/jj206955(v=vs.105).aspx#BKMK_Startingstoppingpausingandresuming

Applies to: Windows Phone 8 and Windows Phone Silverlight 8.1 | Windows Phone OS 7.1

It will not work for Windows phone 8.1 app

查看更多
登录 后发表回答