title: Access controls inside listbox c# (windows Phone 8)
body: <pre><code>         my xaml  code..
        &lt;phone:PhoneApplicationPage.Resources&gt;
      &lt;DataTemplate x:Key="DataTemplate1" &gt;
          &lt;Border BorderBrush="LightGray" BorderThickness="1" Height="150"            Width="500" &gt;
              &lt;Grid Width="500" Height="150" Background="White" &gt;
                  &lt;Grid.ColumnDefinitions&gt;
                      &lt;ColumnDefinition Width="0.9*"/&gt;
                      &lt;ColumnDefinition Width="2.5*"/&gt;
                      &lt;ColumnDefinition Width="1.5*"/&gt;
  
                  &lt;/Grid.ColumnDefinitions&gt;
                  &lt;Grid.RowDefinitions&gt;
                      &lt;RowDefinition Height="*"/&gt;
                  &lt;/Grid.RowDefinitions&gt;
                  &lt;Image Name="imgitem"  Grid.Column="0" Height="Auto" Width="Auto" Source="{Binding ImgSource}" Margin="0,5,4,4" HorizontalAlignment="Left" /&gt;
                  &lt;TextBlock x:Name="txtbindprice"  Text="{Binding _PRICE,ConverterCulture=en-IN,StringFormat=C}" TextWrapping="Wrap"  Grid.Column="1"  Width="350"  Foreground="Black" Height="60" Margin="40,70,20,-10"/&gt;
                  &lt;TextBlock x:Name="txtFinalTotal"  Text="{Binding _FinalTotal}" TextWrapping="Wrap"  Grid.Column="1"  Width="350"  Foreground="Red" Height="60" Margin="40,115,20,-10"/&gt;
                  &lt;TextBlock x:Name="txtITMNAME"  Text="{Binding _ITMNAME }" Padding="1"  Tap="ItmName_Tapped" TextDecorations="Underline" FontSize="24" TextWrapping="Wrap" Grid.Column="1"  FontWeight="Normal" TextTrimming="WordEllipsis"  Foreground="OrangeRed" Width="Auto"  Height="150"  Margin="30,25,10,-10"/&gt;
                  &lt;CheckBox  Grid.Column="2" Grid.Row="0" Background="Black" Foreground="Black" BorderThickness="4" BorderBrush="Red" Margin="10,20,-15,10"  Checked="CheckBox_Checked" Unchecked="CheckBox_UnChecked"  /&gt; 
  
              &lt;/Grid&gt;
          &lt;/Border&gt;
      &lt;/DataTemplate&gt;
  
       &lt;ListBox Height="Auto" Name="lstbxmanual" SelectionMode="Extended" ItemTemplate="{StaticResource DataTemplate1 }"  Width="475" Margin="2,192,0,-39" Background="White"  HorizontalAlignment="Left" Grid.RowSpan="2"&gt;
      &lt;/ListBox&gt;
  </code></pre>
  
  <p>I  want  to  access  textblocks  inside  listbox  based on  selected  index</p>
  
  <pre><code>accessing textblock 
    string  a =txtbindprice.text
  </code></pre>
  
  <p>wont  work  as they  are  inside  data  template  of  listbox..</p>
  
  <p>I  came  across  visual  child  tree  methods  and  some  other  examples..i  cant  find  much  info..</p>
  
  <p>please  help  me  regarding  this...</p>