title: Combobox with Checkboxes
body: <p>I am trying to make a combobox that shows check boxes, and selecting each checkbox will update the text of the combobox to display everything that has been checked.  For some strange reason it works only on the first item in the checkbox and it has completely baffled me as to why.  I have a dummy project that is pretty small that demonstrates it...</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      public ObservableCollection&lt;DataObject&gt; Collection { get; set; }
      #region Private Methods
      public MainWindow()
      {
          InitializeComponent();
          Collection = new ObservableCollection&lt;DataObject&gt;();
          Collection.Add(new DataObject { Name = "item1" });
          Collection.Add(new DataObject { Name = "item2" });
          Collection.Add(new DataObject { Name = "item3" });
          Collection.Add(new DataObject { Name = "item4" });
          Collection.Add(new DataObject { Name = "item5" });
          this.DataContext = Collection;
      }
      #endregion
  
      private void CheckBox_Checked(object sender, RoutedEventArgs e)
      {
          CheckBox chk = sender as CheckBox;
          DataObject data = chk.DataContext as DataObject;
          if ((bool)chk.IsChecked)
              data.CboItems.Add(data.Name);
          else if (data.CboItems.Contains(data.Name))
              data.CboItems.Remove(data.Name);
  
      }
  
  }
  
  public class DataObject : INotifyPropertyChanged
  {
  
      public event PropertyChangedEventHandler PropertyChanged;
      public string Name { get; set; }
      private string cbotext;
      public string CBOText {
          get
          {
              return cbotext;
          }
          set
          {
              cbotext = value;
              FirePropertyChanged("CBOText");
          }
      }
      public ObservableCollection&lt;string&gt; CboItems { get; set; }
  
      private void FirePropertyChanged(string name)
      {
          if (PropertyChanged != null)
              PropertyChanged(this, new PropertyChangedEventArgs(name));
      }
  
      public DataObject()
      {
          CboItems = new ObservableCollection&lt;string&gt;();
          CboItems.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(CboItems_CollectionChanged);
      }
  
      void CboItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
      {
          string text = string.Empty;
          foreach (string item in CboItems)
          {
              if (text == string.Empty)
                  text = item;
              else
                  text += ", " + item;
          }
          CBOText = text;
      }
  }
  </code></pre>
  
  <p>and the Xaml...</p>
  
  <pre><code>    &lt;ComboBox Text="{Binding CBOText}" Width="150" Height="30" ItemsSource="{Binding}" x:Name="cbo" HorizontalContentAlignment="Stretch" IsEditable="True" Margin="12,12,342,270"&gt;
          &lt;ComboBox.ItemTemplate&gt;
              &lt;DataTemplate&gt;     
                  &lt;CheckBox Content="{Binding Name}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked" /&gt;
              &lt;/DataTemplate&gt;
          &lt;/ComboBox.ItemTemplate&gt;
      &lt;/ComboBox&gt;
  </code></pre>
  
  <p>I can see the event CBOText string getting set correctly and firing PropertyChanged, but the combobox does not reflect it unless it's the first item.  Quite weird, any ideas?</p>