title: How to add a list of UIelement in Windows Phone
body: <p>I want to create a page with dynamic control in windows phone.
  While doing this I also want to show a progress bar</p>
  
  <p>Below is my code</p>
  
  <pre><code>protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
  {
      base.OnNavigatedTo(e);
  
      progressstackPanel.Visibility = Visibility.Visible;//progress bar
      formScreen = this;
  
      Deployment.Current.Dispatcher.BeginInvoke(() =&gt;
      {
          if (!isfst)
          {
               DrawScreen();
          }
          else
          {
              //xTitlePanel is only stack panel in my xaml with vertical orientation
              xTitlePanel.UpdateLayout();
          }
          isfst = true;
          progressstackPanel.Visibility = Visibility.Collapsed;
      });
  }
  
  //Code of DrawScreen which is adding control to my stack panels    
  private void DrawScreen()
  {
       if (frm_getset.ChildList != null)
       {
            String[] arr = frm_getset.ChildList.Split(',');
  
            xTitlePanel.Children.Clear();
  
            PrepareControls prepcontrol = new PrepareControls();
  
            foreach (AttributeGetSet a in _Attribute)
            {
                //this will return a stackpanel containing 
                // button/textbox etc.depending on a
                StackPanel sp = prepcontrol.getControl(i, a.Label, a, formScreen);
                try
                {
                     xTitlePanel.Children.Add(sp);
  
                     ///Here I get a eception only one control is added first one
                     /// for anyone it is getting a exception Argument    
                 }
                 catch(Exception ex)
                 {
                      Console.WriteLine(ex.Message);
                 }
  
                 i += 1;
             }
  </code></pre>
  
  <p>The system is adding only one control and when ever it try to execute <code>xTitlePanel.Children.Add(sp);</code> it will get an exception.</p>