title: How to retrieve the controls inside the selected item from a listbox in WP
body: <p>I'm now facing the most common problem faced my many while working with listboxes. Though I found many answers the the forum, nothing seems to work for me or else i have got it wrong. .</p>
  
  <p>I have created a listbox through code. Every listbox item has a stackpanel and within it two textblocks. the stackpanel has vertical orientation.The foreground of the textblocks have been set to specific colors. When an item has been selected or clicked it moves to another page and on the close of the new page it returns to the old page.</p>
  
  <p>My problem is that, when a listbox item has been clicked, it does not show the selection color which is by default the phones accent color before moving to the next page. Is it because the color of the textblocks have already set while creating the listbox?</p>
  
  <p>So i tried to set it the foreground of the selected item through the SelectionChanged() like this</p>
  
  <pre><code>ListBoxItem selItem = (ListBoxItem)(listboxNotes.ItemContainerGenerator.ContainerFromIndex(listboxNotes.SelectedIndex));
  selItem .Foreground = (SolidColorBrush)Application.Current.Resources["PhoneAccentBrush"];
  </code></pre>
  
  <p>But this does not work, and i assume its cuz there is a stackpanel inside the item. </p>
  
  <p>How exactly this needs to be done? Do i need to retrieve the textblocks inside the stackpanel and set the foreground?? I  have not used binding here. Visual Tree Helper???</p>
  
  <p>Thanks</p>
  
  <p>Alfah</p>