• 0

[c# / WPF] Stopping Effect Animation


Question

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.microsoft.com/Forums/en/wpf/thread/5533e0ef-aad0-4a4a-8f16-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);
[/CODE]

Link to comment
https://www.neowin.net/forum/topic/1096249-c-wpf-stopping-effect-animation/
Share on other sites

7 answers to this question

Recommended Posts

  • 0

I'd venture the offending line is this:


daBlur.RepeatBehavior = RepeatBehavior.Forever;
[/CODE]

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.

  • 0

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.

  • 0

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.

This topic is now closed to further replies.
  • Posts

    • This 4K webcam from Acer is now only $59.99 by Taras Buria Those looking for an affordable, high-resolution webcam from a reputable manufacturer can check out the latest deal from Acer, which puts its 4K webcam at a solid price. Thanks to a 14% discount, you can buy this all-metal 4K webcam from Acer for just $59.99. Despite the affordable price tag, the webcam has a pretty large 1/2" CMOS sensor manufactured by Sony. Apart from its size, it supports additional conveniences, such as high dynamic range and phase-detection autofocus (PDAF). Plus, the camera ensures you do not have to buy additional audio equipment, as it comes with two built-in high-sensitivity microphones, a built-in background noise filter, and the ability to pick up your voice from up to 2.5 meters away. Acer is not cheaping out on materials, and the webcam is enclosed in a more premium metal case, which is also good at heat dissipation (high-resolution cameras can get quite hot). And to make sure no one is peeping at you when the camera is in use, there is a magnetic cover also made of metal. Additional conveniences include an LED status indicator and a built-in mount that lets you place a camera on a tripod. Acer 4K Webcam for PC/Mac with All-Metal Unibody Sculpted - $59.99 | 14% off Good to know This Amazon deal is U.S.-specific and not available in other regions unless specified. We only use first-party seller links (at the time of article publishing); ensure that you purchase from a first-party seller link only. Check out Today's Deals on Amazon | or our recent tech deals. Become a Prime member (for Students or SNAP) via Neowin Get Prime Access - Prime for half price (for qualifying Medicaid, EBT, SNAP) Subscribe to Prime Video, Audible Plus, Music Unlimited, or Kindle Unlimited via Neowin As an Amazon Associate, we earn from qualifying purchases.
    • https://www.nvidia.com/en-us/g...back-thread-released-61626/ Best spot to find out if there are any issues b4 u deploy
    • Site is timing out for me.
    • Stop reporting AR glasses as an X inch screen, Y distance away. That is a horseshit meaningless spec. Report on the actual FOV angle. That's all that matters. And for the record, this FOV is ~49degrees. So we're talking about HoloLens level FOV... i.e. it's like looking through a piece of paper at arm's length.
    • I bought a 4TB Samsung 990 Pro for $250 brand new during Black Friday, to give some comparison. Things are getting absolutely ridiculous.
  • Recent Achievements

    • Conversation Starter
      NovaEdgeX earned a badge
      Conversation Starter
    • One Year In
      Console General earned a badge
      One Year In
    • One Year In
      Twozo Technologies earned a badge
      One Year In
    • One Month Later
      Twozo Technologies earned a badge
      One Month Later
    • Week One Done
      Twozo Technologies earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      519
    2. 2
      +Edouard
      185
    3. 3
      PsYcHoKiLLa
      107
    4. 4
      Steven P.
      88
    5. 5
      ATLien_0
      67
  • Tell a friend

    Love Neowin? Tell a friend!