title: WPF elements are in visual tree, but not animated?
body: <p>I'm trying to figure out how to generate animations procedurally.  I create a Line, create four animations, and associate the line's endpoints to the animations.  I add the animations to a storyboard, then I run the storyboard.</p>
  
  <p>The panel itself is visible (I could change the background orange, and that change shows up), but not its children.  The heck am I doing wrong? </p>
  
  <p>Code behind:</p>
  
  <pre><code>using System.Windows.Controls;
  using System.Windows.Media;
  using System.Windows.Shapes;
  using System.Windows.Media.Animation;
  
  namespace MyProject.Animations
  {
      public class MyAnimation : Panel
      {
          private DoubleAnimation[] lineAnimation;
          private Line line;
          private Storyboard storyboard;
  
          public MyAnimation()
          {
              storyboard = new Storyboard();
  
              line = new Line();
              line.StrokeThickness = 4;
              line.Stroke = Brushes.Black;
              this.Children.Add(line);    
  
              lineAnimation = new DoubleAnimation[4];
              for (int i = 0; i &lt; 4; i++)
              {
                  lineAnimation[i] = new DoubleAnimation();
                  lineAnimation[i].Duration = new Duration(TimeSpan.FromSeconds(5));
                  lineAnimation[i].AutoReverse = true;
                  lineAnimation[i].RepeatBehavior = RepeatBehavior.Forever;
  
                  lineAnimation[i].From = 10 * i;
                  lineAnimation[i].To = 100 * i;
  
                  storyboard.Children.Add(lineAnimation[i]);
              }
  
              Storyboard.SetTarget(lineAnimation[0], line);
              Storyboard.SetTargetProperty(lineAnimation[0], new PropertyPath("X1"));
  
              Storyboard.SetTarget(lineAnimation[1], line);
              Storyboard.SetTargetProperty(lineAnimation[1], new PropertyPath("Y1"));
  
              Storyboard.SetTarget(lineAnimation[2], line);
              Storyboard.SetTargetProperty(lineAnimation[2], new PropertyPath("X2"));
  
              Storyboard.SetTarget(lineAnimation[3], line);
              Storyboard.SetTargetProperty(lineAnimation[3], new PropertyPath("Y2"));
  
              storyboard.Begin();
          }
      }
  }
  </code></pre>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Window x:Class="MyProject.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:sdk="http://schemas.microsoft.com/netfx/2009/xaml/presentation/sdk"
          xmlns:local="clr-namespace:MyProject"
          xmlns:a="clr-namespace:Myproject.Animations"
          Title="MyProject"&gt;
  
      &lt;Grid&gt;
          &lt;a:MyAnimation&gt;
      &lt;/Grid&gt;
  
  &lt;/Window&gt;
  </code></pre>
  
  <p>Inspecting the application with Snoop, I see my lines in the visual tree.  But they're not being drawn.  (Note, this is the debug window for the actual application, not the representative code sample I've transcribed.)</p>
  
  <p><img src="https://i.stack.imgur.com/ez9mE.png" alt=""></p>