动画DropShadowEffect颜色

时间:2014-09-18 15:22:43

标签: c# animation storyboard wpf-animation coloranimation

如何使用DropShadowEffect's为已经应用于元素的XAML颜色设置动画,而无需重新应用新的DropShadowEffect

我试过了:

    private void test()
    {
        DropShadowEffect DS_Moon = (DropShadowEffect)Application.Current.Resources["DS_Moon"];

        ColorAnimation DS_Moonlight = new ColorAnimation();
        DS_Moonlight.From = new Color()
        {
            A = (byte)1,
            R = (byte)0,
            G = (byte)0,
            B = (byte)0
        };
        DS_Moonlight.To = new Color()
        {
            A = (byte)1,
            R = (byte)255,
            G = (byte)255,
            B = (byte)255
        };

        DS_Moon.BeginAnimation(SolidColorBrush.ColorProperty, (AnimationTimeline)DS_Moonlight);
    }

但是DS_Moon会返回Null !!

1 个答案:

答案 0 :(得分:1)

我刚才意识到我能做到这一点:

Moon.Effect.BeginAnimation(DropShadowEffect.ColorProperty, (AnimationTimeline)DS_Moonlight);