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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:43:58+00:00 2026-06-07T23:43:58+00:00

I have a StackPanel with UserControls as the children. I would like to apply

  • 0

I have a StackPanel with UserControls as the children. I would like to apply a Storyboard animation which increases the height of the children from 0 to 100 in a second which creates a smooth slide down animation. This will be called for when a new child is added to the StackPanel – StackPanel1.children.Add(usercontrol1). The StackPanel children are UserControls so I do not want to use DataTemplates. Below is an example layout of what I mean.

example layout

Could someone please help me create this as I have no idea how to make it. Thank you.

  • 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-07T23:44:00+00:00Added an answer on June 7, 2026 at 11:44 pm

    Well, that’s more or less a copy paste from the link written in the comment above.
    First, you need to create your control (let’s say usercontrol1) and give it a unique name for the storyboard to reference it.

    EDIT: Below is a code of a simple application that works:

    XAML:

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="800"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <StackPanel Name="StackPanel1">
    
        </StackPanel>
        <Button Grid.Row="1" Click="Button_Click">
    
        </Button>
    </Grid>
    

    and code behind:

    private void Button_Click(object sender, RoutedEventArgs e)
        {
            var usercontrol1 = new Label();
            usercontrol1.Background = new SolidColorBrush(Colors.Red);
            usercontrol1.Content = "Hello";
            usercontrol1.Name = "UniqueName" + System.Guid.NewGuid().ToString("N");
            RegisterName(usercontrol1.Name, usercontrol1);
    
            StackPanel1.Children.Add(usercontrol1);
            // Create a DoubleAnimation to animate the width of the button.
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.From = 0;
            myDoubleAnimation.To = 100;
            myDoubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(1000));
    
            // Configure the animation to target the button's Width property.
            Storyboard.SetTargetName(myDoubleAnimation, usercontrol1.Name);
            Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Button.HeightProperty));
    
            // Create a storyboard to contain the animation.
            Storyboard myWidthAnimatedButtonStoryboard = new Storyboard();
            myWidthAnimatedButtonStoryboard.Children.Add(myDoubleAnimation);
            myWidthAnimatedButtonStoryboard.Begin(usercontrol1);
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have usercontrols which inherit a base class which looks like this: BasePage.cs: using
I have a stackpanel with some usercontrols that are added or removed during runtime.
I have a Silverlight UserControl which uses the ContentPropertyAttribute to exposes the Children property
I have a UserControl that I would like to be able to have more
I have a control in a base assembly with Content that I would like
I have a UserControl which basically wraps a ListBox like this - <ListBox x:Name=lb
I have a UserControl named AddressTemplate , which contains a StackPanel with an assortment
I have a StackPanel in my WinRT C# Metro app that I want to
I have a Stackpanel and want that the items automatically set their sizes regarding
I have a StackPanel inside of a ScrollViewer. I have a slider that does

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.