开发者

ComboBox Binding error

开发者 https://www.devze.com 2023-04-04 04:30 出处:网络
If I have a ComboBox like this: <ComboBox x:Name=\"SampleComboBox\" Width=\"100\" Margin=\"10, 0, 40, 0\"

If I have a ComboBox like this:

<ComboBox x:Name="SampleComboBox" Width="100" Margin="10, 0, 40, 0" 
                          ItemsSource="{Binding Path=SelectedSamplesNames}"  />

I have a property that this ComboBox is binding to when my items are selected in an associated table. So when my application loads开发者_如何学编程 its data, it crashes with this error:

InavlidOperationException was unhandled {"Collection was modified; enumeration operation may not execute."}

InnerException:null

Message:Collection was modified; enumeration operation may not execute.

No disassembly.

I'm not sure why I get this error. When I first populated the ComboBox with a different property, the SamplesNameList, which is a List of names that gets created from the data, no problem. Now that I want to modify the ComboBox, to be bound to only the selected items of these names in a Table, I get this error. Any thoughts? Thanks.


This would happen if you modify the collection in a background thread.

Don't do that; most collections are not thread safe.

0

精彩评论

暂无评论...
验证码 换一张
取 消