title: Deselect listbox item in c#
body: <p>I am using listboxes in a windows phone application code written in c#.</p>
  
  <pre><code>&lt;Grid&gt;
  &lt;ListBox x:Name ="gsecList" ItemsSource="{Binding}" SelectionChanged="ShowGsecDetails"&gt;
  </code></pre>
  
  <p><strong>Event Handler :</strong></p>
  
  <pre><code>private void ShowGsecDetails(object sender, SelectionChangedEventArgs e)
  {
      string indexCode = gsecList.SelectedIndex.ToString();
      NavigationService.Navigate(new Uri("/contactDetail.xaml?type=gsec&amp;index="+indexCode, UriKind.Relative));
  }
  </code></pre>
  
  <p>I am using the eventhandler <code>listBox1.SelectionChanged</code> to navigate to some other page depending on the selection made by the user. Now when I navigate back to the page again I see the listITem still selected. How can I deselect that item? I tried to use <code>listBox1.SelectedIndex = -1</code>. But that seemed to call up the selectionChanged event handler.</p>