Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weirdest combobox exception: GeneratorPosition '-1,1' "passed to Remove does not have Offset equal to 0". Parameter name: position

Tags:

c#

silverlight

I honestly have no idea what's going on here, I can only find this error mentioned in a few specific places around the whole of the internet. I'm using Silverlight4. I have a combobox that is bound to an observable collection. The observable collection has two things in it. If I try and set the combobox's selectedindex to 0, it works fine, but if I try and set it to one, I get the exception:

"GeneratorPosition '-1,1' "passed to Remove does not have Offset equal to 0". Parameter name: position"

..Any thoughts at all? The only really useful reference I found to this was http://qa.social.msdn.microsoft.com/Forums/en-US/silverlightgen/thread/e6e07c42-4d64-4973-965d-c4b6dd32cfd9 and it seems to indicate that it's a problem native to Silverlight.

like image 829
cost Avatar asked Jan 27 '13 10:01

cost


1 Answers

For those occasional googlers that come across this, I don't recall exactly how I fixed this, but it wound up being something silly like setting the combobox's ItemsSource to null, setting a new ObservableCollection equal to the old one, and then assigning the new one to the combobox's ItemsSource.

Really I think this comes down to Silverlight being kind of buggy. I'm curious why it's actually happening if someone wants to go and use the reflector, but the above should help all the same.

like image 51
cost Avatar answered Nov 09 '22 05:11

cost