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 8437899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:33:37+00:00 2026-06-10T07:33:37+00:00

I am learning c# and wpf. I have the project running in Visual Studio

  • 0

I am learning c# and wpf. I have the project running in Visual Studio 2012. To learn C# and WPF better I am making a practice application which happens to be a Simon Says game. I have two windows. The first window has a “PLAY!” button that shows the next window. This window has 4 buttons. I have an array of integers so that the player has to press the buttons in order. To show the player the order, I wanted to animate each button one by one in the order that is generated in the array.

The buttons are 4 different colors and the animation for each I made from a Storyboard in Blend. The animation turns the button from its original color to red and then back over the span of two seconds.

The animation works properly however, all the buttons animate at the same time. I wanted the first button to animate, then when it is finished, the next one and so forth. How would I best do this using C# and WPF. Thanks for the help. I can upload code if needed.

The function that runs the animation

public void startbtn_Click(object sender, RoutedEventArgs e)
{
    // Show the animation sequence for each button
    // up until the current level. (getCurrentLevel is currently set to 5)
    for (int i = 0; i <= engine.getCurrentLevel(); i++)
    {
        // engine.animate(i) returns the button at sequence i to animate
        animate(engine.animate(i));
    }
}

private void animate(int index)
{
    // Storyboard for each button is in the format of ButtonAnimation_INDEX where INDEX is 1, 2, 3 or 4
    Storyboard btnAnimation = (Storyboard)this.Resources["ButtonAnimation_" + index];
    if (btnAnimation != null)
    {
        btnAnimation.Begin();   
    }
}
  • 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-06-10T07:33:38+00:00Added an answer on June 10, 2026 at 7:33 am

    I figured it out using the Completed event. I have the function now check to see if the current sequence is lower than the current level. If it is that means another button can be animated. So the completed event runs the function again with the next button to animate.

    public void startbtn_Click(object sender, RoutedEventArgs e)
    {
        engine.resetSequence(); // Start from sequence 0
        // Animate first button
        animate(engine.animate()); 
    }
    
    
    private void animate(int index)
    {
    
        // Storyboard for each button is in the format of ButtonAnimation_INDEX where INDEX is 1, 2, 3 or 4
           Storyboard btnAnimation = (Storyboard)this.Resources["ButtonAnimation_" + index];
           // Added completed event function handler
           btnAnimation.Completed += btnAnimation_Completed;
           if (btnAnimation != null)
           {
               btnAnimation.Begin();   
            }
    }
    
    
    void btnAnimation_Completed(object sender, EventArgs e)
    {
         // If another button can be animated in the sequence
         if (engine.CurrentSequence() < engine.getCurrentLevel())
         {
             // Increment the sequence position
             engine.nextSequence();
             // Run the animation with the next button
             animate(engine.animate());
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to write a simple WPF learning project which creates a set
Hi I have been learning WPF with Expression Blend 4 last few days and
I've been learning wpf for about a week now.. and i have a basic
New to wpf and through a learning curve. I have a userControl with a
Sorry, I'm thrashing around a bit learning MVVM, WPF, and XAML simultaneously. I have
I'm learning WPF and have been trying to create a toolstrip. Is there a
I'm still at the early stages of learning WPF and have decided to try
Just learning WPF databinding and have a gap in my understanding. I've seen a
As of last night, I decided to start learning about WPF and have been
I'm in the process of learning WPF and I have a problem with a

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.