How do I place programatically a TextBlock in a Grid. This is my XAML code: I need to add the TextBlock which is commenented out programatically. There is a SetRow method but it does not exist for the ContentPanel or the LayoutRoot only for the Grid control (which Grid is this referring to ?) Also it seems I can not access the Items grid, is this because it is inside a stackpanel ? How can this be solved ? What I need to do is to place the textblock inside a specific row inside a grid and the grid is inside a stackpanel and datatemplate. Any ideas how to do this ?
Thanks, Jani
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="ContentPanel" Grid.Row="0" Margin="12,0,12,0">
<phone:LongListSelector x:Name="MainLongListSelector" Margin="0,0,-12,0" ItemsSource="{Binding Items}" SelectionChanged="MainLongListSelector_SelectionChanged">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel x:Name="stack" Margin="0,0,0,17">
<Grid x:Name="Items" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding LineOne}" Grid.Row="0" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="{Binding LineTwo}" Grid.Row="1" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
<!--<TextBlock Text="Hello" Grid.Row="3" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/> -->
</Grid>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</Grid>
</Grid>