I'm brand new to Windows Phone 7 development, and almost as equally new to Silverlight. I have a ListBox with a DataTemplate, StackPanel, and TextBlocks like so:
<ListBox Height="355" HorizontalAlignment="Left" Margin="6,291,0,0" Name="detailsList" VerticalAlignment="Top" Width="474" Background="#36FFFFFF">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Width="50" Text="{Binding Ticker}" />
<TextBlock Width="50" Text="{Binding Price}" />
<TextBlock Width="50" Text="{Binding GainLoss}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I have some C# code to populate it:
var info = new List<StockInfo>();
info.Add(new StockInfo { Ticker = "C", Price = "5.18", GainLoss = "10" });
info.Add(new StockInfo { Ticker = "WEN", Price = "4.18", GainLoss = "12" });
info.Add(new StockInfo { Ticker = "CBB", Price = "5.22", GainLoss = "210" });
detailsList.ItemsSource = info;
And that all works fine. My question is: how do I add/remove additional 'textblocks' to the listbox dynamically (at runtime)? Also, how do I put column headers on the list box?