十三、“孩子”的动画——动态添加

第一步:在XAML文件中

 <StackPanel x:Name="sp1" HorizontalAlignment="Left" Height="259" Margin="395,278,0,0" VerticalAlignment="Top" Width="167">
            <StackPanel.ChildrenTransitions>
                <TransitionCollection>
                    <AddDeleteThemeTransition></AddDeleteThemeTransition> //此处有好多种动画效果
                </TransitionCollection>
            </StackPanel.ChildrenTransitions>
        </StackPanel>

第二步:在.cs文件中

 private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Button btn = new Button();
            btn.Content = DateTime.Now;
            sp1.Children.Add(btn); //动态添加按钮
          
        }

原文地址:https://www.cnblogs.com/suinuaner/p/thirteen3.html