title: Create a bunch of buttons programmatically in C# Win Phone 8 app
body: <p>I have a problem in my C# file. I have to create 6 buttons programmatically on specific  location. but my for loop doesn't work..</p>
  
  <p>just one button shows and not all the buttons.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Net;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Navigation;
  using Microsoft.Phone.Controls;
  using Microsoft.Phone.Shell;
  //using System.Array;
  
  namespace AimPass
  {
       public partial class main : PhoneApplicationPage
       {
      public main()
       {
          InitializeComponent();
  
      }
  
  private void newbutton(object sender, RoutedEventArgs e)
      {
   // How many buttons do you want ?
          int NumOfButtons = 6;
          // X Location of each created button in the panel
          int loc = 20;
          for (int i = 1; i &lt;= NumOfButtons; i++)
          {
              Button btn = new Button();
              {
                  btn.Name = "Btn-" + i.ToString();
                btn.Size= new Size(50, 20);
                 btn.Tag = i;
                  btn.Content = "Browse-" + i.ToString();
                btn.location = new Point(5, loc);
              }
              //Add Click event Handler for each created button
             btn.Click += Buttons_Click;
              loc += 20;
              // Add the created btn to grid
              grid.Children.Add(btn);
          }
  }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>there are 2,3 errors comes..
        using System.Windows.Controls.Buttons    does not contain a definition of location and size...???</p>
  
  <pre><code>    btn.Click += Buttons_Click; does not exist in current context..
  </code></pre>
  
  <p>And loop is not working..Just one buttons comes except 6 buttons..</p>
  
  <p>I wanna add button on a specific location..So these errors comes to my requirement..
  Thanx in advance for solving this..:)</p>