• 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

    • It saddens me when cars are such dull colours now. Mine is bright metallic blue and I absolutely adore it for standing out in contrast to that depressing backdrop of traffic.
    • Sparkle 2.20.0 by Razvan Serea Sparkle is a free, open-source Windows optimization tool designed to make your PC faster, cleaner, and more private. With Sparkle, you can easily debloat Windows by removing unnecessary apps and services, disable Microsoft tracking to enhance privacy, and apply performance tweaks to boost speed. Its cleaner removes junk and temporary files, while every change is safe and fully reversible. Sparkle also features a modern, user-friendly interface with automatic updates, making system maintenance simple. Explore over 39 tweaks, from disabling telemetry and hibernation to optimizing network and game settings, all aimed at customizing and enhancing your Windows experience. Sparkle supports Windows 10 and 11. Sparkle 2.20.0 changelog: Debloat Tweak has animated border New homepage loading UI New Tweak Modal (Markdown Supported) Refactored GPU Detection Added Tests with vitest Added foobar2000 to apps Added Localsend to apps Updated Modal Styles Added styles for disabled inputs Added Animated Border to debloat-windows tweak Bumped dependencies Refactor System info logic for speed Tweak info modals now support Markdown Added Clear System info cache to settings Redesigned Home Page Loading UI Changed Some Icons around the app Download: Sparkle 2.20.0 | Portable | ~100.0 MB (Open Source) Links: Sparkle Website | Github | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • lol it was a typo, fixed! haha imagine an actual 4TB Gen4 NVMe for $40 in 2026
    • Get over it, has nothing to do with my point.
    • I really don't like these rounded corners and huge borders in the viewport. They just waste space without anything in return.
  • Recent Achievements

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

    1. 1
      +primortal
      517
    2. 2
      +Edouard
      184
    3. 3
      PsYcHoKiLLa
      106
    4. 4
      Steven P.
      88
    5. 5
      ATLien_0
      68
  • Tell a friend

    Love Neowin? Tell a friend!