title: How to bind Gridview with data at runtime in Windows Phone 7?
body: <p>In table creation, listbox method doesnt suits to my project need as the table goes beyond phone view. Gridview suited exactly. But I dont know how to add rows at runtime.Could anyone help me please?</p>
  
  <pre><code>namespace myApp
  {
      public class Person
      {
          public string Id { get; set; }
          public string Name { get; set; }
  
          public Person(string dId, string dName)
          {
              this.Id = dId;
              this.Name = Name;            
          }
      }
  }
  </code></pre>
  
  <p>This is my XAML code:</p>
  
  <pre><code> &lt;Grid x:Name="LayoutRoot" Background="Transparent"&gt;
          &lt;gridView:GridView x:Name="GridView1" CellSpacing="1" RowSpacing="1" ItemsSource="{Binding}"&gt;
              &lt;gridView:GridView.Columns&gt;
                  &lt;gridView:GridViewTextColumn Header="ID" Binding="{Binding} /&gt;
                  &lt;gridView:GridViewTextColumn Header="Name" Binding="{Binding}"/&gt;
  
              &lt;/gridView:GridView.Columns&gt;
          &lt;/gridView:GridView&gt;
      &lt;/Grid&gt;
  </code></pre>
  
  <p>To create Statically, i have no problem that I created an <strong>viewmodel</strong> for person object(e.g personVM) and I created static resource(in XAML) to that object and bound with my gridview. </p>
  
  <pre><code>&lt;phone:PhoneApplicationPage.Resources&gt; 
  &lt;local:PersonViewModel x:Key="PersonVM"/&gt; 
  &lt;/phone:PhoneApplicationPage.Resources&gt;    
  
  &lt;gridView:GridView x:Name="GridView1" CellSpacing="1" RowSpacing="1" ItemsSource="{Binding Source={StaticResource PersonVM}, Path=Data}"
  &gt;
  </code></pre>
  
  <p>How to do this dynamically? (it can be done by *<em>observablecollection??)</em>*I cant do with datacontext.</p>
  
  <pre><code>GridView1.DataContext = new Person("S403","Arthos"); 
  </code></pre>
  
  <p>Its not working.How can I identify columns in code.Help me please.</p>