1

How to animate a DropShadowEffect's color that has been already applied to an element with XAML without the need to re-apply a new DropShadowEffect?

I tried this:

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

But DS_Moon returns Null!!

AnjumSKhan
  • 9,051
  • 1
  • 21
  • 33
Enumy
  • 811
  • 2
  • 8
  • 20

1 Answers1

1

I just realized that i can do this:

Moon.Effect.BeginAnimation(DropShadowEffect.ColorProperty, (AnimationTimeline)DS_Moonlight);
Enumy
  • 811
  • 2
  • 8
  • 20