Sumit Kumawat

Sumit Kumawat

  • NA
  • 454
  • 414.6k

How to update/refresh CompositeCollection in wpf combobox?

Mar 30 2013 12:33 AM

Hi all,

I am using one wpf combo box control and adding one static combo box item and one list to its ItemsSource

using CompositeCollection. Below are the code.

             

 <ComboBox Name="cb"  Height="25" Width="180"  SelectionChanged="cb_SelectionChanged">
                    <ComboBox.ItemsSource>
                        <CompositeCollection>
                            <ComboBoxItem Name="cbi"   Content="Create a new account" Selected = "cbi_Selected"/>
                            <CollectionContainer x:Name="colletion"  />
                        </CompositeCollection>
                    </ComboBox.ItemsSource>

  </ComboBox>

and i am also assigning one string list to CompositeCollection and it is working fine. But whenever i am adding new a item to the list and assinging updated list to CompositeCollection. At that time i am getting below error

"collection was modified enumeration operation may not execute"

Please help me out inupdating my CompositeCollection.

Thanks