title: Why does my combobox freeze when the itemssource changes?
body: <p>Steps to Reporoduce:</p>
  
  <p>When the app starts, open the combobox so the items get generated.  Now click the "Click Me!" button.  In the code behind, the itemssource of the combobox is changed.  Now try to open the combobox again.  The combobox freezes for at least 5 seconds even though only 2 items are in the bound collection.  This is just a test app.  In my real application, there are more than 2 items and the lag is unbearable.  I've tried this with virtualizing on and off.  It makes no difference.</p>
  
  <p>What is taking so long?  How do I fix this?  If there's no direct fix, is there a work around?</p>
  
  <p>XAML:</p>
  
  <pre><code>    &lt;StackPanel&gt;
          &lt;ComboBox x:Name="cbo" DisplayMemberPath="Junk1"&gt;&lt;/ComboBox&gt;
          &lt;Button Content="Click Me!" Click="btn_Click"&gt;&lt;/Button&gt;
      &lt;/StackPanel&gt;
  </code></pre>
  
  <p>CODE:</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      public MainWindow()
      {
          InitializeComponent();
          this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
      }
  
      ObservableCollection&lt;Junk&gt; junk1 = new ObservableCollection&lt;Junk&gt;() {
          new Junk() { Junk1 = "jdkf", Junk2 = "fjdfkasjd;klfj" },
          new Junk() { Junk1 = "jfdk;a", Junk2 = "fjkdljf" } };
  
      ObservableCollection&lt;Junk&gt; junk2 = new ObservableCollection&lt;Junk&gt;() {
          new Junk() { Junk1 = "fjkdfhsdjk", Junk2 = "fdjkah;" },
          new Junk() { Junk1="", Junk2 = "asdfj" } };
  
      void MainWindow_Loaded(object sender, RoutedEventArgs e)
      {
          this.cbo.ItemsSource = junk1;
      }
  
      private void btn_Click(object sender, RoutedEventArgs e)
      {
          if (this.cbo.ItemsSource == junk1)
              this.cbo.ItemsSource = junk2;
          else
              this.cbo.ItemsSource = junk1;
          this.cbo.UpdateLayout();
      }
  }
  
  public class Junk
  {
      public string Junk1 { get; set; }
      public string Junk2 { get; set; }
  }
  </code></pre>