Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 449665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:47:31+00:00 2026-05-12T21:47:31+00:00

How can I remove a storyboard in XAML (i.e. RemoveStoryboard action in a DataTrigger)

  • 0

How can I remove a storyboard in XAML (i.e. RemoveStoryboard action in a DataTrigger) but keep the value that was animated. Similar to the Animatable.BeginAnimation:

If the animation’s BeginTime is null, any current animations will be removed and the current value of the property will be held.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T21:47:31+00:00Added an answer on May 12, 2026 at 9:47 pm

    RemoveStoryboard’s primary use is to remove the animated values and set them back to their un-animated state. In most cases you can just switch the call to PauseStoryboard or StopStoryboard instead, depending on the specific case. The only exception is when you need to free up resources held by the storyboard or use it for another purpose.

    If you really want to remove the storyboard and keep the property values, you must set the animated values directly on the properties. This can be done by setting each value to the animated value, something like this:

    void CopyAnimatedValuesToLocalValues(DependencyObject obj)
    {
      // Recurse down tree
      for(int i=0; i<VisualTreeHelper.GetChildrenCount(obj); i++)
        CopyAnimatedValuesToLocalValues(VisualTreeHelper.GetChild(obj, i));
    
      var enumerator = obj.GetLocalValueEnumerator();
      while(enumerator.MoveNext())
      {
        var prop = enumerator.Current.Property;
        var value = enumerator.Current.Value as Freezable;
    
        // Recurse into eg. brushes that may be set by storyboard, as long as they aren't frozen
        if(value!=null && !value.IsFrozen)
          CopyAnimatedValuesToLocalValues(value);
    
        // *** This is the key bit of code ***
        if(DependencyPropertyHelper.GetValueSource(obj, prop).IsAnimated)
          obj.SetValue(prop, obj.GetValue(prop));
    
      }
    }
    

    Call this right before you remove the storyboard to copy the animated values.

    Edit A comment was made that this code may be unnecessary because calling BeginAnimation with BeginTime=null achieves a similar effect.

    While it is true that BeginAnimation with BeginTime=null makes it looks as if the values were copied to local, a later call to RemoveStoryboard will cause the values to revert. This is because BeginAnimation with BeginTime=null causes the prior animation to hold its values pending the start of the new animation, but does nothing to affect the local values.

    The code above actually overwrites local values, so all animations can be removed and the objects will still have their new values. So if you really want to call RemoveStoryboard and still keep your values, you will need the code I wrote above or something like it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we can remove formula from one cell by cell.setCellFormula(null) . but if i want
I am looking for an API that can remove bundle items added in a
Is there anyway or any addin for VS2010 that can remove all the comments
I'm in need of a regular expression that can remove unnecessary/extra parenthesis in a
$target.remove() can remove the element,but now I want the process to be down with
How can remove similar element(ul) in class .makhzan after click on one of 111
Anyone has a regex that can remove the attributes from a body tag for
We can remove all symbols in a particular context by using Remove[context`*] . But
It can remove title by setting requestWindowFeature(Window.FEATURE_NO_TITLE) in onCreat(). But the title display first,
I know that you can remove a folder that is empty with rmdir. And

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.