title: Using a Storyboard animation on a programmatically-added control
body: <p>I'm trying to fade in a new control to my application's "app" area which is programmatically added after the existing controls are removed. My code looks like this:</p>
  
  <pre><code>        void settingsButton_Clicked(object sender, EventArgs e)
      {
          ContentCanvas.Children.Clear();
  
          // Fade in settings panel
          NameScope.SetNameScope(this, new NameScope());
  
          SettingsPane s = new SettingsPane();
          s.Name = "settingsPane";
  
          this.RegisterName(s.Name, s);
          this.Resources.Add(s.Name, s);
  
          Storyboard sb = new Storyboard();
  
          DoubleAnimation settingsFade = new DoubleAnimation();
          settingsFade.From = 0;
          settingsFade.To = 1;
          settingsFade.Duration = new Duration(TimeSpan.FromSeconds(0.33));
          settingsFade.RepeatBehavior = new RepeatBehavior(1);
          Storyboard.SetTargetName(settingsFade, s.Name);
          Storyboard.SetTargetProperty(settingsFade, new PropertyPath(UserControl.OpacityProperty));
  
          ContentCanvas.Children.Add(s);
  
          sb.Children.Add(settingsFade);
          sb.Begin();
      }
  </code></pre>
  
  <p>However, when I run this code, I get the error "No applicable name scope exists to resolve the name 'settingsPane'."</p>
  
  <p>What am I possibly doing wrong? I'm pretty sure I've registered everything properly :(</p>