title: WPF ComboBox prevent event on select item by code
body: <p><strong>I have rephrased my question in EDIT 2</strong></p>
  
  <p>All, I have a combobox in WPF. When I set SelectedIndex property, it fires a SelectionChanged event, which is the correct behavior. But what I want is to make ComboBox not fire an event when I set the SelectedIndex property programatically. Is there a way to do it?</p>
  
  <p>I am using .Net 4.5</p>
  
  <p>EDIT 1: Code</p>
  
  <pre><code>public void AddLocation()
  {
      List&lt;String&gt; locations = new List&lt;String&gt;();
  
      //LocationBox is the name of ComboBox
      LocationBox.ItemsSource = locations;
  
      locations.Add("L1");
      locations.Add("B1");
      locations.Add("B3");
      LocationBox.SelectedIndex = 2; //&lt;-- do not want to raise SelectionChanged event programmatically here
      locations.Add("G1");
      locations.Add("G2");
      locations.Add("F1");
      locations.Add("F3");
  }
  
  private void LocationBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  {
      Console.WriteLine(LocationBox.SelectedIndex);
  }
  </code></pre>
  
  <p>EDIT 2: Rephrasing the question</p>
  
  <p>I want to select an item in ComboBox silently i.e., without user interaction (using code/programmatically) so it doesn't fire a SelectionChanged event. How can I do that?</p>