title: ListBox.SelectedItem
body: <p>I have a <code>ListBox</code> with items that fill <code>TextBox</code>es.  How do I identify the text string that is selected when a selection is made from the <code>ListBox</code>. Here's my XAML code for the <code>ListBox</code>:</p>
  
  <pre><code>&lt;StackPanel x:Name="InputPanel" Orientation="Horizontal" HorizontalAlignment="Left"&gt;
      &lt;StackPanel&gt;
          &lt;TextBlock Text="Input" Style="{StaticResource H2Style}"/&gt;
          &lt;TextBlock Text="Select Scenario:" Style="{StaticResource H3Style}"/&gt;
          &lt;ListBox x:Name="ScenarioList" Margin="0,0,20,0" HorizontalAlignment="Left" SelectionChanged="ScenarioList_SelectionChanged"&gt;
              &lt;ListBox.ItemTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;TextBlock Text="{Binding Name}"/&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ListBox.ItemTemplate&gt;
              &lt;ListBoxItem x:Name="Scenario1"&gt;
                  &lt;TextBlock Style="{StaticResource ListBoxTextStyle}" Text="1) Pick a single photo" /&gt;
              &lt;/ListBoxItem&gt;
              &lt;ListBoxItem x:Name="Scenario2"&gt;
                  &lt;TextBlock Style="{StaticResource ListBoxTextStyle}" Text="2) Pick multiple files" /&gt;
              &lt;/ListBoxItem&gt;
              &lt;ListBoxItem x:Name="Scenario3"&gt;
                  &lt;TextBlock Style="{StaticResource ListBoxTextStyle}" Text="3) Pick a folder" /&gt;
              &lt;/ListBoxItem&gt;
              &lt;ListBoxItem x:Name="Scenario4"&gt;
                  &lt;TextBlock Style="{StaticResource ListBoxTextStyle}" Text="4) Save a file" /&gt;
              &lt;/ListBoxItem&gt;
          &lt;/ListBox&gt;
      &lt;/StackPanel&gt;
  </code></pre>
  
  <p>I have tried all kinds of things in my <code>selection_changed</code> method. Here's the latest one:</p>
  
  <pre><code>object selectedItem = ScenarioList.SelectedItem;
  ListBoxItem selected = this.ScenarioList.ItemContainerGenerator.ContainerFromItem(this.ScenarioList.SelectedItem) as ListBoxItem;
  string tempStr = selected.Content.ToString();
  </code></pre>