Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit Threading issue with combobox causes White Screen of Death, any suggestions?
4 replies. Latest Post by samcov on December 16, 2008.
(0)
wildert
Member
40 points
41 Posts
12-12-2008 1:06 AM |
I have a combobox and on its Loaded event I go make a web service call to populate its dropdownitems and set the selected item to the first item in the Items collection, This obviously happens async, On the callback I actually populate the items and set the selected value. The combobox is inside a tab control with two tabs. When I swich between tabs quickly to activate the combobox's load event, and then quickly mouse click the combobox dropdown, I get a white screen of death. Firefox tells me its an ArgumentOutOfRangeException. What i'm pretty sure is happening is that during the combobox's dropdown-ing code, my async callback happens and the Items Collection gets cleared and re-created.
Any ideas around this? Anyone else having threadng related white screens of death?
TomBeeby
Participant
1151 points
188 Posts
12-12-2008 2:48 AM |
i'm not sure if this is the precise issue that you are facing, but i've certainly hit run-time exceptions trying to set the selected index of a combo box that is not visible...
i find it annoying that by default, the combobox selectedindex is -1, with nothing selected (as opposed to HTML drop downs which function in a similar way to radio buttons). so, even if there are many items in the combobox, until the user selects one, the 'selected item text area' is blank... because of this, populating a combobox always seem to be a two-step affair: 1. bind a collection 2. set selected index to 0 - and step 2. needs to be executed very, very carefully...
samcov
964 points
376 Posts
12-15-2008 1:49 AM |
wildert: I have a combobox and on its Loaded event I go make a web service call to populate its dropdownitems and set the selected item to the first item in the Items collection, This obviously happens async, On the callback I actually populate the items and set the selected value. The combobox is inside a tab control with two tabs. When I swich between tabs quickly to activate the combobox's load event, and then quickly mouse click the combobox dropdown, I get a white screen of death. Firefox tells me its an ArgumentOutOfRangeException. What i'm pretty sure is happening is that during the combobox's dropdown-ing code, my async callback happens and the Items Collection gets cleared and re-created. Any ideas around this? Anyone else having threadng related white screens of death?
Yes, I'm having the same problem. It appears that when you clear the items collection, the combobox goes crazy, and won't let you add new items.
I wonder if binding it to a List would get better behavior, or even removing all but one item... who knows.
This is surely a bug.
12-15-2008 2:41 AM |
I found a solution, but it isn't as nice as I would like it to be.
I destroy the combobox(remove it from your tree), and recreate another one when I need to place new values into it.
Like I said, it required a lot of code changes, but it works perfectly. I placed a ContentControl where I needed the combo box, and named it of course, then it was easy to get a reference to the combobox as shown below.
12-16-2008 4:12 PM |
There is an alternative solution in this thread.
http://silverlight.net/forums/t/41425.aspx