Hello
I have a listbox in windows phone and i want had bind it with all contacts in my Phone. I want to check/uncheck all items in listbox on button click. My XML code is 
 
               
                   
                       

                           
                               
                               
                           
                       
                   
               
           

            


            
           
           
           
            

And C# code is 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Microsoft.Phone.Data;
using Microsoft.Phone.UserData;
using Microsoft.Phone.Tasks;
using System.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;


namespace MyPhoneBackup
{
    public partial class CreateContactBackups : PhoneApplicationPage
    {
        //AddressChooserTask addressChooserTask;
        //PhoneNumberChooserTask addressChooserTask;

        

        public CreateContactBackups()
        {
            InitializeComponent();
            
            Contacts cContacts = new Contacts();
            cContacts.SearchCompleted += new EventHandler(ContactsSearch);
            cContacts.SearchAsync(String.Empty, FilterKind.DisplayName, null);



            /* addressChooserTask = new PhoneNumberChooserTask();
            addressChooserTask.Completed += new EventHandler(addressChooserTask_Completed); 
            //addressChooserTask.Completed += new EventHandler(addressChooserTask_Completed); */


        }

        /*
         void addressChooserTask_Completed(object sender, PhoneNumberResult e)
         {
             if (e.TaskResult == TaskResult.OK)
             {
                 txtDisplay.Text = "The address for " + e.DisplayName + " is " + e.PhoneNumber;
             }
         }*/


        private void Button_Click_2(object sender, RoutedEventArgs e)
        {


            /*try
            {
                addressChooserTask.Show();
            }
            catch (System.InvalidOperationException ex)
            {
            }*/

        }


        void ContactsSearch(object sender, ContactsSearchEventArgs e)
        {
            try
            {
                lstcontacts.DataContext = e.Results;
            }
            catch (System.Exception)
            {
                txtResults.Text = "No Results Available";
            }
            if (lstcontacts.Items.Any())
            {
                txtResults.Text = "Below is the List of Contacts";
            }
            else
            {
                txtResults.Text = "No Results Available";
            }
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
                       //CheckBox contactChk = lstcontacts.SelectedItem as CheckBox;
           // SearchVisualTree(this.lstcontacts);
           // int count22 = lstcontacts.Children.Count;

            //StackPanel FirstPanel = GetChild(lstcontacts) as StackPanel;
            //StackPanel SecondPanel = GetChild(FirstPanel) as StackPanel;
            //int i = lstcontacts.Items.Count;
            //for (int j = 0; j <= i; j++ )
            //{

            //    ListBoxItem item = this.lstcontacts.ItemContainerGenerator.ContainerFromIndex(Convert.ToInt32(j)) as ListBoxItem;
            //    CheckBox contactChk = FindFirstElementInVisualTree(item);
            //    contactChk.IsChecked = false;
            //}

            StackPanel FirstPanel = GetChild(lstcontacts) as StackPanel;
            StackPanel SecondPanel = GetChild(FirstPanel) as StackPanel;

            for (int n = 0; n < SecondPanel.Children.Count; n++)
            {
               // CheckBox CheckBoxItem = GetChild(SecondPanel);
                ListBoxItem item = this.lstcontacts.ItemContainerGenerator.ContainerFromIndex(Convert.ToInt32(n)) as ListBoxItem;
                CheckBox CheckBoxItem = FindFirstElementInVisualTree(item);
                CheckBoxItem.IsChecked = false;
            }

        }

        /**/

        public T GetChild(DependencyObject obj) where T : DependencyObject
        {
            DependencyObject child = null;

            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
            {
                child = VisualTreeHelper.GetChild(obj, i);

                if (child != null && child.GetType() == typeof(T))
                    break;

                else if (child != null)
                {
                    child = GetChild(child);

                    if (child != null && child.GetType() == typeof(T))
                        break;
                }
            }
            return child as T;
        }

        /**/

        private void SearchVisualTree(DependencyObject targetElement)
        {
            var count = VisualTreeHelper.GetChildrenCount(targetElement);
            if (count == 0)
                return;

            for (int i = 0; i < count; i++)
            {
                var child = VisualTreeHelper.GetChild(targetElement, i);
                if (child is TextBlock)
                {
                    TextBlock myItems = (TextBlock)child;
                    if (myItems.Text == "Item2")                    {
                        myItems.Foreground = new SolidColorBrush(Colors.Green);
                        return;
                    }
                }
                else
                {
                    SearchVisualTree(child);
               }
            }

        }

        private T FindFirstElementInVisualTree(DependencyObject parentElement) where T : DependencyObject
        {
            var count = VisualTreeHelper.GetChildrenCount(parentElement);

            if (count == 0)
                return null;
            for (int i = 0; i <= count; i++)
            {
                var child = VisualTreeHelper.GetChild(parentElement, i);
                if (child != null && child is T)
                {
                    return (T)child;
                }
                else
                {
                    var result = FindFirstElementInVisualTree(child);
                    if (result != null)
                        return result;
                }
            }
            return null;
        }

        public void chbox_checked(object sender, RoutedEventArgs e) {
            


        }
   
    }

   

}


In this code only first two items in list box are being checked/uncheck on button click. Please help me how can i check/uncheck all items in list on button click