【问题标题】:Windows phone create animation of controlsWindows phone 创建控件的动画
【发布时间】:2014-07-05 01:39:33
【问题描述】:

我需要加载一些图像并在网格上显示(带有简单的动画)。我有

            Image img = IconWithId(i);
            // set some properties
            //...
            img.Tap += img_Tap;
            img.ImageOpened += img_ImageOpened;
            gameView.Children.Add(img);

在 img_ImageOpened 事件中我创建动画

void img_ImageOpened(object sender, RoutedEventArgs e)
    {
        Image img = sender as Image;
        Storyboard story = new Storyboard();

        DoubleAnimation dAnimation = new DoubleAnimation();
        dAnimation.From = 0;
        dAnimation.To = 1;
        dAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(100));
        Storyboard.SetTarget(dAnimation, img);
        Storyboard.SetTargetProperty(dAnimation, new PropertyPath(OpacityProperty));

        story.Children.Add(dAnimation);

        story.Begin();
    }

我想我有动画应该显示图像,但它不起作用。加载的图像没有动画。我能做些什么? PS当图像关闭时我需要动画。我认为使用事件卸载 对不起我的英语

【问题讨论】:

    标签: c# windows-phone


    【解决方案1】:

    我在带有 Phone 8 SDK 的 Windows Phone 8 上测试了您的代码

    您的代码运行良好。

    您需要将持续时间更改为更长的时间。 100ms 太快了。您将无法足够快地看到它。

    把它改成这样的更长的东西

    dAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(5000));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-21
      • 1970-01-01
      • 2017-01-22
      • 1970-01-01
      • 2011-08-30
      • 1970-01-01
      • 2017-06-14
      相关资源
      最近更新 更多