title: How to get the selected item from the listpicker in windows phone 8?
body: <p>I am using this code for create listpicker in windows phone.</p>
  
  <pre class="lang-xaml prettyprint-override"><code>&lt;StackPanel Height="148" Margin="0,100,0,0"&gt;
     &lt;toolkit:ListPicker Grid.Row="0" FontFamily="Segoe WP Semibold" Height="176" x:Name="Additional_Time" ItemTemplate="{StaticResource PickerItemTemplate}" FullModeItemTemplate="{StaticResource PickerFullModeItemTemplate}" FullModeHeader="Cities" SelectedIndex="0" CacheMode="BitmapCache" Header="Choose Exit Time" FontSize="30" SelectionChanged="Additional_Time_SelectionChanged"/&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p>and use this grid resources </p>
  
  <pre class="lang-xaml prettyprint-override"><code>&lt;Grid.Resources&gt;
          &lt;DataTemplate x:Name="PickerItemTemplate"&gt;
              &lt;StackPanel Orientation="Horizontal"&gt;
                  &lt;Border Background="LightGreen" Width="34" Height="34"&gt;
                      &lt;TextBlock Text="{Binding Country}" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
                  &lt;/Border&gt;
                  &lt;TextBlock Text="{Binding Name}" Margin="12 0 0 0"/&gt;
              &lt;/StackPanel&gt;
          &lt;/DataTemplate&gt;
          &lt;DataTemplate x:Name="PickerFullModeItemTemplate"&gt;
              &lt;StackPanel Orientation="Horizontal" Margin="16 21 0 20"&gt;
                  &lt;TextBlock Text="{Binding Name}" Margin="16 0 0 0" FontSize="43" FontFamily="{StaticResource PhoneFontFamilyLight}"/&gt;
  
                  &lt;TextBlock Text="{Binding Language}" Foreground="Green"/&gt;
              &lt;/StackPanel&gt;
          &lt;/DataTemplate&gt;
      &lt;/Grid.Resources&gt;
  </code></pre>
  
  <p>Below code for insert item into listpicker</p>
  
  <pre class="lang-cs prettyprint-override"><code>List&lt;Cities&gt; source = new List&lt;Cities&gt;();
          //List&lt;Items&gt; source = new List&lt;Items&gt;();
          source.Add(new Cities() { Name = " 00 : 30 " });
          source.Add(new Cities() { Name = " 01 : 00 " });
          source.Add(new Cities() { Name = " 01 : 30 " });
          source.Add(new Cities() { Name = " 02 : 00 " });
          source.Add(new Cities() { Name = " 02 : 30 " });
          source.Add(new Cities() { Name = " 03 : 00 " });
          source.Add(new Cities() { Name = " 03 : 30 " });
          source.Add(new Cities() { Name = " 04 : 00 " });
          source.Add(new Cities() { Name = " 04 : 30 " });
          source.Add(new Cities() { Name = " 05 : 00 " });
          source.Add(new Cities() { Name = " 05 : 30 " });
          source.Add(new Cities() { Name = " 06 : 00 " });
          source.Add(new Cities() { Name = " 06 : 30 " });
          source.Add(new Cities() { Name = " 07 : 00 " });
  
          this.Additional_Time.ItemsSource = source;
  </code></pre>
  
  <p>My Question was how to get the selected item from this listpicker.</p>
  
  <p>I tried different code for get the selected item from that listpicker it's throw null value exception or invalid cast exception.</p>
  
  <pre class="lang-cs prettyprint-override"><code>private void Additional_Time_SelectionChanged(object sender, SelectionChangedEventArgs e)
      {
          var selectedItem = (sender as ListPicker).SelectedItem;
          int selindex = Additional_Time.SelectedIndex;// lp.SelectedIndex; //just for testing
          MessageBox.Show(selindex.ToString()); //just for testing
          MessageBox.Show((Additional_Time.SelectedItem as ListPicker).ToString());
      }
  </code></pre>
  
  <p>Please help me to solve this problem.</p>
  
  <p>Thanks in advance.</p>