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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:09:36+00:00 2026-06-02T22:09:36+00:00

Created a simple jquery-nivo-like slider using wpf and want to add an animation between

  • 0

Created a simple jquery-nivo-like slider using wpf and want to add an animation between slides that fades the background, changes the background image, and finally fades back in the new background image. I was trying to do the following….I get no errors, background changes, but there wasn’t any animation either…what am I doing wrong?

public void SetSlider(MyItem item)
    {
        //Fade out
        DoubleAnimation fadeOutAnimation = new DoubleAnimation(0, TimeSpan.FromSeconds(3));
        fadeOutAnimation.AutoReverse = false;
        grdContent.Background.BeginAnimation(Brush.OpacityProperty, fadeOutAnimation);

        //set background
        ImageBrush bgBrush = new ImageBrush();
        bgBrush.ImageSource = new BitmapImage(new Uri(item.ImageFile.SavedDirectoryAndFile, UriKind.Absolute));
        grdContent.Background = bgBrush;

        //Set title
        txtTitle.Text = item.Title;

        //set Summary
        txtSummary.Text = item.Summary;

        //Fade back in
        DoubleAnimation fadeInAnimation = new DoubleAnimation(1, TimeSpan.FromSeconds(3));
        fadeInAnimation.AutoReverse = false;
        grdContent.Background.BeginAnimation(Brush.OpacityProperty, fadeInAnimation);        
} 
  • 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-02T22:09:39+00:00Added an answer on June 2, 2026 at 10:09 pm

    Figured it out… I had to apply the animation to the brush that was set in the background property…not the background property itself and I had to make some timing changes. Here is my final solution:

    public void SetSlider(MyItem item)
        {
            //Create the fade out animation. 
            DoubleAnimation fadeOutAnimation = new DoubleAnimation(0, TimeSpan.FromMilliseconds(500));
            fadeOutAnimation.AutoReverse = false;
    
            //wait until the first animation is complete before changing the background, or else it will appear to just "fadeIn" with now fadeout.
            fadeOutAnimation.Completed += delegate(object sender, EventArgs e)
            {
                //once the fadeout is complete set the new back ground and fade back in. 
                //Create a new background brush. 
                ImageBrush bgBrush = new ImageBrush();
                bgBrush.ImageSource = new BitmapImage(new Uri(item.ImageFile.SavedDirectoryAndFile, UriKind.Absolute));
                bgBrush.Opacity = 0;
    
                //Set the grid background to the new brush. 
                grdContent.Background = bgBrush; 
    
                //Set the brush...(not the background property) with the animation. 
                DoubleAnimation fadeInAnimation = new DoubleAnimation(1, TimeSpan.FromMilliseconds(500));
                fadeInAnimation.AutoReverse = false;
                bgBrush.BeginAnimation(Brush.OpacityProperty, fadeInAnimation);
            };
    
            //Fade out..before changing the background. 
            var currentBackground = grdContent.Background;
            currentBackground.BeginAnimation(Brush.OpacityProperty, fadeOutAnimation);
    
            //Set title
            txtTitle.Text = item.Title;
    
            //set Summary
            txtSummary.Text = item.Summary;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a simple animation using jQuery and the mouseenter / mouseleave. It
I have simple jQuery Mobile site created using asp.net mvc 2 and uses basic
I've created a simple jQuery slider for my website, and I was wondering if
I've created a simple auto-complete control using JQuery UI. I have a default value
I've created a simple form and I'm using the Datatables jQuery plugin to display
I created a simple a jQuery function that is to be used for developer
I have created a simple page that use jQuery, so include jquery.min.js. But I
I have created a simple JQuery script with hovering effect on some links. The
I've created a simple placeHolder for some extra javascript in jQuery - The issue
I'm trying to follow http://www.foliotek.com/devblog/make-table-rows-sortable-using-jquery-ui-sortable/ And have created a very simple example http://jsfiddle.net/6wbZQ/ It's

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.