title: Get SelectedItem from listbox in code behind
body: <p>I have a ListBox populated with a list from ImageDomainService (RIA Services). I want to select one image from the ListBox and show the bigger version of the image beside it. Images are stored separate in /images/ folder How do I get the ImageName binding from ListBox to the url string in code behind like below? </p>
  
  <pre><code>void AlbumView_Loaded(object sender, RoutedEventArgs e)
  {
      ImageDomainContext ctx = new ImageDomainContext();
      listBoxImages.ItemsSource = ctx.Images;
      ctx.Load(ctx.GetImagesListQuery());
  }  
  </code></pre>
  
  <p>XAML:</p>
  
  <pre><code>&lt;ListBox x:Name="listBoxImages" ItemsSource="{Binding}"
      SelectionChanged="ListBox_SelectionChanged"&gt;  
      &lt;ListBox.ItemTemplate&gt;  
          &lt;DataTemplate&gt;  
              &lt;TextBlock x:Name="ImageNameTextBox" Text="{Binding ImageName}" /&gt;  
              &lt;TextBlock Text="{Binding ImageDescription}" /&gt;  
          &lt;/DataTemplate&gt;  
      &lt;/ListBox.ItemTemplate&gt;  
  &lt;/ListBox&gt;  
  </code></pre>
  
  <p>Event Handler:</p>
  
  <pre><code>private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  {
      Image _image = new Image();
      BitmapImage bi = new BitmapImage();
  
      // string url = ???????????
      bi.UriSource = new Uri(string.Format("images/{0}", url), UriKind.Relative);
  
      _image.Source = bi;
  
      _image.Width = 500;
      _image.Height = 300;
  
      bigImageBorder.Child = _image;
  }  
  </code></pre>