title: How to dynamically create textblock based on the entries parsed
body: <p>I am trying to parse down a web API, Based on the entries obtained i want show all bank account transaction (list of all entries) associated with a single account and want to show it in dynamically created text block.
  Similar like this:-</p>
  
  <p><img src="https://i.stack.imgur.com/uciQi.png" alt="enter image description here"></p>
  
  <p>Here is my parser class</p>
  
  <pre><code>public class Transaction
  {
  public string dec { get; set; }
  public string amt { get; set; }
  public string date { get; set; }
  }
  
  public class Loginresponse
  {
  public List&lt;Transaction&gt; transaction { get; set; }
  }
  </code></pre>
  
  <p>Here dec- Description, amt- Amount, i have successfully parsed the web API.</p>
  
  <pre><code>&lt;Grid Name="accountdetails" Margin="0,0,0,0" Background="#66ac22" HorizontalAlignment="Left" Width="456" Grid.ColumnSpan="2"&gt;
                      &lt;TextBlock Grid.Row="0"  VerticalAlignment="Center" Margin="10,0,0,0" Text="No." Foreground="White"/&gt;
                      &lt;TextBlock  VerticalAlignment="Center" Margin="66,0,319,0" Text="Date." Foreground="White"/&gt;
                      &lt;TextBlock VerticalAlignment="Center" Margin="166,0,140,0" Text="Description" Foreground="White"/&gt;
                      &lt;TextBlock VerticalAlignment="Center" Margin="364,0,0,0" Text="Amount" Foreground="White"/&gt;
                      &lt;ItemsControl Name="accdetails" ItemsSource="{Binding Path=transaction}" Margin="0,10,0,-440"&gt;
                          &lt;ItemsControl.ItemTemplate&gt;
                              &lt;DataTemplate&gt;
                                  &lt;StackPanel Orientation="Horizontal" Background="Black"&gt;
                                      &lt;TextBlock Text="{Binding dec}" Foreground="Black" /&gt;
                                      &lt;TextBlock Text="{Binding amt}" Foreground="Black"/&gt;
                                      &lt;TextBlock Text="{Binding date}" Foreground="Black"/&gt;
                                  &lt;/StackPanel&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/ItemsControl.ItemTemplate&gt;
                      &lt;/ItemsControl&gt;
                      &lt;/Grid&gt;
  </code></pre>
  
  <p>My class file:-</p>
  
  <pre><code> protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
      {
          base.OnNavigatedTo(e);
          try
          {
              IDictionary&lt;string, string&gt; parameters = this.NavigationContext.QueryString;
              if (parameters.ContainsKey("key"))
              {
                  var root1 = JsonConvert.DeserializeObject&lt;RootObject&gt;(parameters["key"]);
                  this.accdetails.DataContext = root1.loginresponse.transaction;
              }
          }
          catch (Exception)
          {
  
          }
      }
  </code></pre>
  
  <p>Now i am unable to figure out how to dynamically create textblock and show all this details obtained from parser.
   Any kind of guidance, suggestion, or correct method of writing code with details would be appreciated. </p>
  
  <pre><code> &lt;Grid x:Name="LayoutRoot"&gt;
      &lt;phone:Pivot Title="" Style="{StaticResource PivotStyle1}"&gt;
  
          &lt;phone:PivotItem Header="transactions" FontSize="20"&gt;
              &lt;Grid Margin="0,0,0,420" Background="#f9f9f9"&gt;
                  &lt;Grid.RowDefinitions&gt;
                      &lt;RowDefinition Height="Auto"/&gt;
                      &lt;RowDefinition Height="Auto"/&gt;
                      &lt;RowDefinition Height="Auto"/&gt;
                      &lt;RowDefinition Height="Auto"/&gt;
                  &lt;/Grid.RowDefinitions&gt;
                  &lt;Grid Name="accountdetails" Margin="0,0,0,0" Background="#66ac22" HorizontalAlignment="Left" Width="456" Grid.ColumnSpan="2"&gt;
                      &lt;TextBlock VerticalAlignment="Center" Margin="10,0,0,0" Text="No." Foreground="White"/&gt;
                      &lt;TextBlock VerticalAlignment="Center" Margin="66,0,319,0" Text="Date." Foreground="White"/&gt;
                      &lt;TextBlock VerticalAlignment="Center" Margin="166,0,140,0" Text="Description" Foreground="White"/&gt;
                      &lt;TextBlock VerticalAlignment="Center" Margin="364,0,0,0" Text="Amount" Foreground="White"/&gt;
                      &lt;ListBox x:Name="ListBox1" Margin="5,32,0,-340"
                             Width="450" HorizontalAlignment="Left" Padding="0" VerticalAlignment="Center"
                             ItemsSource="{Binding}" &gt;
                          &lt;ListBox.ItemTemplate&gt;
                              &lt;DataTemplate&gt;
                                  &lt;StackPanel Orientation="Horizontal" &gt;
                                      &lt;TextBlock Grid.Column="0" Text="{Binding no}" Foreground="Black" Margin="5,5,0,0" HorizontalAlignment="Left"/&gt;
                                      &lt;TextBlock Grid.Column="1" Text="{Binding date}" Foreground="Black" Margin="30,5,0,0" HorizontalAlignment="Left"  /&gt;
                                      &lt;TextBlock Grid.Column="2" Text="{Binding dec}" Foreground="Black" Margin="40,5,0,0" HorizontalAlignment="Left"/&gt;
                                      &lt;TextBlock Grid.Column="3" Text="{Binding amt}" Foreground="Black" Margin="120,5,80,0" HorizontalAlignment="Left" VerticalAlignment="Center"/&gt;
                                  &lt;/StackPanel&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/ListBox.ItemTemplate&gt;
                      &lt;/ListBox&gt;
  </code></pre>
  
  <p>Now i am getting the list of text but i unable to show it properly in the grids.</p>