title: Get the multiple selected checkbox values from listbox
body: <p>In my windows phone application I am getting all contacts and attach checkbox with each like below:</p>
  
  <pre><code>xaml page
          &lt;Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"&gt;
              &lt;StackPanel Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,10"&gt;
                  &lt;TextBlock x:Name="ContactResultsLabel" Text="results are loading..." Style="{StaticResource PhoneTextLargeStyle}" TextWrapping="Wrap"&gt;&lt;/TextBlock&gt;
                  &lt;ListBox x:Name="ContactResultsData" ItemsSource="{Binding listOfContacts}" Height="293" Margin="24,0,0,0"&gt;
                      &lt;ListBox.ItemTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;StackPanel Orientation="Horizontal"&gt;
                              &lt;CheckBox Name="contactChk" IsChecked="false" Foreground="Black" Background="Black" BorderBrush="White"&gt;&lt;/CheckBox&gt;
                              &lt;TextBlock x:Name="ContactResultsName" Text="{Binding Name}" FontSize="50"&gt;&lt;/TextBlock&gt;
                              &lt;/StackPanel&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/ListBox.ItemTemplate&gt;
                  &lt;/ListBox&gt;
              &lt;/StackPanel&gt;
              &lt;Button x:Name="btn_addContacts"
                      Content="Add"
                      Width="200"
                      Height="70"
                      FontSize="25"
                      Foreground="Blue"
                      Background="AliceBlue"
                      Click="btn_addContacts_Click" Margin="130,496,126,-89"&gt;&lt;/Button&gt;
  
          &lt;/Grid&gt;
  </code></pre>
  
  <p>and below is the xaml.cs page:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Net;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Data;
  using System.Windows.Navigation;
  using Microsoft.Phone.Controls;
  using Microsoft.Phone.Shell;
  using Microsoft.Phone.UserData;
  
  namespace GetContacts
  {
      public partial class SelectionOfContacts : PhoneApplicationPage
      {
          List&lt;CustomContact&gt; listOfContact = new List&lt;CustomContact&gt;();
          public SelectionOfContacts()
          {
              InitializeComponent();
  
              Contacts cons = new Contacts();
              cons.SearchCompleted += new EventHandler&lt;ContactsSearchEventArgs&gt;(Contacts_SearchCompleted);
              cons.SearchAsync(string.Empty, FilterKind.None, "Contacts Test #1");
          }
          private void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
          {
              try
              {
                  //List&lt;CustomContact&gt; listOfContact = new List&lt;CustomContact&gt;();
                  foreach (var c in e.Results)
                  {
                      CustomContact contact = new CustomContact();
                      contact.Name = c.DisplayName;
                      int count = c.PhoneNumbers.Count();
                      for (int i = 0; i &lt; count; i++)
                      {
                          if (count &gt; 0 &amp;&amp; c.PhoneNumbers.ElementAt(i).PhoneNumber != null &amp;&amp; !string.IsNullOrEmpty(c.PhoneNumbers.ElementAt(i).PhoneNumber))
                          {
                              contact.Number[i] = c.PhoneNumbers.ElementAt(i).PhoneNumber.ToString();
                          }
                          else
                          {
                              contact.Number[i] = "";
                          }
                      }
                      listOfContact.Add(contact);
  
                  }
  
                  ContactResultsData.ItemsSource = listOfContact;
  
              }
              catch (System.Exception)
              {
                  //No results
              }
              if (ContactResultsData.Items.Any())
              {
                  ContactResultsLabel.Text = "results";
              }
              else
              {
                  ContactResultsLabel.Text = "no results";
              }
          }
  
          private void btn_addContacts_Click(object sender, RoutedEventArgs e)
          {
              var selectvalue = ContactResultsData.SelectedItem;
          }
      }
  }
  </code></pre>
  
  <p>And its working fine and at this line <code>var selectvalue = ContactResultsData.SelectedItem</code> get me only only selected value of checkbox but I want to get the multiple selected checkbox values from listbox, kindly suggest me, what I do, waiting for your reply.
  Thanks.</p>