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

The Archive Base Latest Questions

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

I want to add animation to the loading user controls in a StackPanel .

  • 0

I want to add animation to the loading user controls in a StackPanel.

So I add these lines to the existing project :

control.Loaded += UserControlLoaded;

and

    public void UserControlLoaded(object sender, System.Windows.RoutedEventArgs e)
    {
        UserControl control = (UserControl)sender;

        DoubleAnimation fadeInAnimation = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(5)));
        Storyboard.SetTarget(fadeInAnimation, control);
        Storyboard.SetTargetProperty(fadeInAnimation, new PropertyPath(UIElement.OpacityProperty));
        Storyboard sb = new Storyboard();
        sb.Children.Add(fadeInAnimation);
        sb.Begin();
    }

It works good but I want to change it to scale the user control in both axis from 0 to 1 within 2 seconds but I can’t find the code to set target property of the story board to the LayoutTransform X and Y axis !

The transform was made in MS Blend by this way :

How can I do it programmatically.

Thanks in advance for your kind attention.

  • 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-31T07:45:13+00:00Added an answer on May 31, 2026 at 7:45 am

    The code that would animate the control’s LayoutTransform depends on the kind of Transform used. Provided that it simply is a ScaleTransform, you could write this:

    FrameworkElement control = sender as FrameworkElement;
    ScaleTransform transform = control.LayoutTransform as ScaleTransform;
    DoubleAnimation scaleAnimation =
        new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(2)));
    
    transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
    transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
    

    When the LayoutTransform was created with Blend, it is most certainly not simply a ScaleTransform, but a TransformGroup with a ScaleTransform as first child. You would then retrieve the ScaleTranform by something like this:

    TransformGroup transformGroup = control.LayoutTransform as TransformGroup;
    ScaleTransform transform = transformGroup.Children[0] as ScaleTransform;
    

    And again i forgot the reason why animating a Transform like this won’t work by means of a Storyboard. Instead of directly calling BeginAnimation on the ScaleTransform object, I’ve tried the code below, but without success.

    DoubleAnimation xScaleAnimation =
        new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(2)));
    Storyboard.SetTarget(xScaleAnimation, transform);
    Storyboard.SetTargetProperty(xScaleAnimation,
        new PropertyPath(ScaleTransform.ScaleXProperty));
    
    DoubleAnimation yScaleAnimation =
        new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(2)));
    Storyboard.SetTarget(yScaleAnimation, transform);
    Storyboard.SetTargetProperty(yScaleAnimation,
        new PropertyPath(ScaleTransform.ScaleYProperty));
    
    Storyboard sb = new Storyboard();
    sb.Children.Add(xScaleAnimation);
    sb.Children.Add(yScaleAnimation);
    sb.Begin();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a user control, and now I want to add custom properties
I need to add a simple loading animation on top a my view..and want
I'm doing a simple slideUp animation on an object. I want to add attribute
I want to add an animation to PopupControlExtender .... so , what is the
I want to add an animation to all links' color change. I mean, without
I want to add my sliderButton after the animation has ended but this doesn't
I want to add animation to a view while changing its hidden mode i.e
I want to add a subview with animation. I am using add sub view
I need some informative help about animation. Want to add animation in iPhone Application..
I have a C# winforms project and I want to add a bit of

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.