【问题标题】:Animation not working in Windows Phone 8.1动画在 Windows Phone 8.1 中不起作用
【发布时间】:2014-08-21 19:10:51
【问题描述】:

我只是想在我的 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);
}

我将“Source”更改为 new PropertyPath("Source"),它适用于 Windows Phone 7 应用程序。

【问题讨论】:

  • 那么您是说Storyboard.SetTargetProperty(animationBg, new PropertyPath("Source")); 适用于 Windows 7,但不适用于 Windows 8?那很奇怪。我也会尝试使用这个:Storyboard.SetTargetProperty(animationBg, new PropertyPath(Image.SourceProperty));
  • 它在 8.1 中不起作用

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


【解决方案1】:

如 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 操作系统 7.1

它不适用于 Windows phone 8.1 应用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-13
    • 1970-01-01
    • 2015-02-23
    • 1970-01-01
    • 1970-01-01
    • 2017-06-14
    • 2014-06-25
    相关资源
    最近更新 更多