Geeks With Blogs
Marc Schluper Business Intelligence for fun
It looks like Silverlight 5's ComboBox is more restrictive. In Silverlight 4 I could change the ItemsSource of a ComboBox that had a SelectedItem != null, while in Silverlight 5 I have to set SelectedItem to null before I assign a new ItemsSource. Why even mention this? Isn't this obvious? Well, the Silverlight 4 ComboBox simply ignored the SelectedItem and did not complain about the new ItemsSource, so moving to Silverlight 5 may cause some (unexpected) pain. But the real reason for this post is the exception that is thrown: InvalidOperationException ("Cannot call StartAt when content generation is in progress.") Saying this (Cannot call StartAt when content generation is in progress) is not very helpful, is it? Moreover, this exception is not thrown at a place that refers to the cause of the problem (the assignment to a ComboBox's ItemsSource): System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.StartAt At that point the whole stack trace is grayed out. (It does hint toward the ComboBox' SetContentPresenter, though.) So if you got confused, searched for the error message, and ended up here, you may want to check your ComboBoxes' ItemsSource assignments. Posted on Monday, October 10, 2011 8:34 AM | Back to top


Comments on this post: Silverlight 5 ComboBox more rigid: Cannot call StartAt when content generation is in progress

# re: Silverlight 5 ComboBox more rigid: Cannot call StartAt when content generation is in progress
Requesting Gravatar...
I came here after searching for the exception message. You probably saved me a few hours of head scratching. Thanks!
Left by efdee on Jan 16, 2014 2:57 AM

# re: Silverlight 5 ComboBox more rigid: Cannot call StartAt when content generation is in progress
Requesting Gravatar...
Did you come up with a method to clear the selected value in xaml binding, or did you assign the items source in code? Thanks.
Left by KCS on Oct 15, 2014 8:58 AM

# re: Silverlight 5 ComboBox more rigid: Cannot call StartAt when content generation is in progress
Requesting Gravatar...
Thank you very much for this information! I'm binding to a CollectionViewSource and got the same exception. Setting SelectedItem to null before calling CollectionViewSource.View.Refresh() seems to solve it!
Left by M on Jul 13, 2016 9:31 AM

Your comment:
 (will show your gravatar)


Copyright © Marc Schluper | Powered by: GeeksWithBlogs.net