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

  • Home
  • SEARCH
  • 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 6212167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:28:01+00:00 2026-05-24T06:28:01+00:00

I wrote the following code. It tries to create a storyboard that does the

  • 0

I wrote the following code. It tries to create a storyboard that does the following:

  1. fade in for 500ms
  2. pause for 1000ms
  3. fade out for 500ms

But at run time get an System.InvalidOperationException followed by the following output:

Additional information: Multiple animations in 
  the same containing Storyboard cannot target the
  same property on a single element.

This seems to suggest its trying to do all the animations at once rather than sequentially.

private Storyboard createStoryboard()
{
  Storyboard board = new Storyboard();

  addFadeToStoryboard(board, 0, 1, 500);
  addFadeToStoryboard(board, 1, 1, 1000);

  DoubleAnimation fadeOut = addFadeToStoryboard(board, 1, 0, 500);

  fadeOut.Completed += new EventHandler(onFadeCompleted);

  Storyboard.SetTarget(board, this);

  return board;
}

private DoubleAnimation addFadeToStoryboard(Storyboard board, 
  double fadeFrom, double fadeTo, double milliseconds)
{
  DoubleAnimation fade = new DoubleAnimation()
  {
    Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds)),
    From = fadeFrom,
    To = fadeTo,
    RepeatBehavior = new RepeatBehavior(1)
  };

  Storyboard.SetTargetProperty(fade,
    new PropertyPath(UIElement.OpacityProperty));

  board.Children.Add(fade);

  return fade;
}

How can I make it sequential? Am I misinterpreting something fundamental about storyboards?

Thanks

  • 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-24T06:28:02+00:00Added an answer on May 24, 2026 at 6:28 am

    I’ve solved this by creating my own sequencer class. It has a dependency on a LinkedList class, so you’ll have to swap that out with the standard one if you want to use this code:

    using System;
    using System.Windows.Media.Animation;
    
    namespace YourNamespace
    {
      // An object that contains multiple storyboards, and fires off 
      // subsequent ones as they finish.
    
      public class StoryboardSequencer
      {
        public StoryboardSequencer()
        {
        }
    
        public void add(Storyboard board)
        {
          m_boards.add(board);
          board.Completed += new EventHandler(onBoardCompleted);
        }
    
        // Starts the storyboard from the first.
        // If already started, this call is ignored.
        public void begin()
        {
          if (m_boards.size() > 0)
          {
            m_currentBoardIndex = 0;
            beginCurrentBoard();
          }
          else
          {
            onLastBoardCompleted();
          }
        }
    
        // Stops and rewinds.
        // Does not call completed handler.
        public void stop()
        {
          if (m_currentBoardIndex != -1)
          {
            Storyboard board = m_boards.get(m_currentBoardIndex);
            if (board != null)
            {
              board.Stop();
            }
    
            m_currentBoardIndex = -1;
          }
        }
    
        private void beginCurrentBoard()
        {
          Storyboard board = m_boards.get(m_currentBoardIndex);
          if (board == null)
          {
            onLastBoardCompleted();
          }
          else
          {
            board.Begin();
          }
        }
    
        // Triggered when the sequence completes.
        public event EventHandler Completed;
    
        private void onBoardCompleted(object sender, EventArgs e)
        {
          m_currentBoardIndex++;
    
          if (m_currentBoardIndex >= m_boards.size())
          {
            onLastBoardCompleted();
          }
          else
          {
            beginCurrentBoard();
          }
        }
    
        private void onLastBoardCompleted()
        {
          m_currentBoardIndex = -1;
          Completed.Invoke(this, null);
        }
    
        private LinkedList<Storyboard> m_boards = new LinkedList<Storyboard>();
    
        // The current storyboard playing, or -1 if none.
        private int m_currentBoardIndex = -1;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i wrote following code to create a linkbutton programmatically, but its showing like lable
I wrote following code...but i am getting Error like: Error 1 'LoginDLL.Class1.Login(string, string, string)':
In C++Builder, I wrote the following code (in Button1Click handler), When I run in
I've got the following bit of code (that another developer wrote) that I need
I tried to create image from BLOB. I try following code but it is
if wrote the following code and do not understand why the trace returns false:
I wrote the following code: import java.lang.*; import DB.*; private Boolean validateInvoice(String i) {
I'm working with the jQuery Validation plugin and I wrote the following code which
I needed some simple string encryption, so I wrote the following code (with a
I wrote the following code: Function find_results_idle() Public iRaw As Integer Public iColumn As

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.