Welcome Guest! To access all forums & features, please register an account or sign-in. → Why register?



[c# / WPF] Stopping Effect Animation


7 replies to this topic - - - - -

#1 James Rose

    Software Developer

  • 1,920 posts
  • Joined: 20-January 04
  • Location: New York City

Posted 05 August 2012 - 20:21

Hello gang,

I have a menu that has a "glow" effect that works fine, but I cannot find out how to stop it. I have tried setting: effTitleFade = null; but the effect keeps going. What am I missing?


I found the example here:http://social.msdn.m...16-c681ec94d346

					   DropShadowEffect effTitleFade = new DropShadowEffect();
					    effTitleFade.Color = Color.FromArgb(0, 0, 255, 255);
					    effTitleFade.Direction = 0;
					    effTitleFade.BlurRadius = 0;
					    effTitleFade.ShadowDepth = 0;
					    this.txtTitle.Effect = effTitleFade;
					    DoubleAnimation daBlur = new DoubleAnimation(0, 25, new Duration(TimeSpan.FromSeconds(4)));
					    daBlur.AutoReverse = true;
					    daBlur.RepeatBehavior = RepeatBehavior.Forever;
					    effTitleFade.BeginAnimation(DropShadowEffect.BlurRadiusProperty, daBlur);



#2 +Asik

  • 6,020 posts
  • Joined: 26-October 05

Posted 06 August 2012 - 00:41

I'd venture the offending line is this:
						daBlur.RepeatBehavior = RepeatBehavior.Forever;


#3 OP James Rose

    Software Developer

  • 1,920 posts
  • Joined: 20-January 04
  • Location: New York City

Posted 06 August 2012 - 15:37

View PostDr_Asik, on 06 August 2012 - 00:41, said:

I'd venture the offending line is this:
						daBlur.RepeatBehavior = RepeatBehavior.Forever;

Thanks... but no. I want the daBlur to repeat forever until the user selects an option (moving from one menu to another) At that time I need to shut off the glow from this MenuItem and turn it on with another.

#4 Kami-

    ♫ d(-_-)b ♫

  • 3,625 posts
  • Joined: 28-July 08
  • Location: SandBox

Posted 07 August 2012 - 00:10

this.txtTitle.Effect = effTitleFade;
^ unset this?

#5 OP James Rose

    Software Developer

  • 1,920 posts
  • Joined: 20-January 04
  • Location: New York City

Posted 07 August 2012 - 13:14

View PostKami-, on 07 August 2012 - 00:10, said:

this.txtTitle.Effect = effTitleFade;
^ unset this?

Ah, ok. I'll give that a try. Thank you!

Edit: That worked, thanks.
this.txtTitle.Effect = null;


#6 Aethec

    Neowinian Senior

  • 2,214 posts
  • Joined: 02-May 10

Posted 07 August 2012 - 13:26

If you want to remove the effect you just assigned, simply assign Effect to null.

To answer your original question, setting effTitleFade to null changes the effTitleFade variable to point to null instead of the object you created. But your TextBlock's Effect property still holds a reference to that object.

If I give you a piece of paper with my address on it, you'll be able to come to my house and paint it green. But if you erase what was written on the piece of paper, my house still exists. To make it disappear, I'd need to lose my own piece of paper that says where I live, at which point the city notices that nobody uses that house anymore and destroys it to replace it with something else the next time space is needed. Here, the pieces of paper are the references to my house and the city is the garbage collector.

#7 OP James Rose

    Software Developer

  • 1,920 posts
  • Joined: 20-January 04
  • Location: New York City

Posted 07 August 2012 - 17:59

View PostAethec, on 07 August 2012 - 13:26, said:

If you want to remove the effect you just assigned, simply assign Effect to null.

To answer your original question, setting effTitleFade to null changes the effTitleFade variable to point to null instead of the object you created. But your TextBlock's Effect property still holds a reference to that object.

If I give you a piece of paper with my address on it, you'll be able to come to my house and paint it green. But if you erase what was written on the piece of paper, my house still exists. To make it disappear, I'd need to lose my own piece of paper that says where I live, at which point the city notices that nobody uses that house anymore and destroys it to replace it with something else the next time space is needed. Here, the pieces of paper are the references to my house and the city is the garbage collector.

Thank you very much for the clarification.

#8 Kami-

    ♫ d(-_-)b ♫

  • 3,625 posts
  • Joined: 28-July 08
  • Location: SandBox

Posted 07 August 2012 - 18:20

View PostJames Rose, on 07 August 2012 - 13:14, said:

Ah, ok. I'll give that a try. Thank you!

Edit: That worked, thanks.
this.txtTitle.Effect = null;

You're welcome ;)