Skip to main content

Microsoft Silverlight

Answered Question Threading issue with combobox causes White Screen of Death, any suggestions?RSS Feed

(0)

wildert
wildert

Member

Member

40 points

41 Posts

Threading issue with combobox causes White Screen of Death, any suggestions?

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
TomBeeby

Participant

Participant

1151 points

188 Posts

Re: Threading issue with combobox causes White Screen of Death, any suggestions?

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
samcov

Participant

Participant

969 points

379 Posts

Re: Threading issue with combobox causes White Screen of Death, any suggestions?

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.

"The difference between genius and stupidity is that genius has its limits." - Albert Einstein

samcov
samcov

Participant

Participant

969 points

379 Posts

Answered Question

Re: Threading issue with combobox causes White Screen of Death, any suggestions?

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.

ComboBox dropdown = (ComboBox)ContentControlName.Content;

"The difference between genius and stupidity is that genius has its limits." - Albert Einstein

samcov
samcov

Participant

Participant

969 points

379 Posts

Re: Threading issue with combobox causes White Screen of Death, any suggestions?

There is an alternative solution in this thread.

http://silverlight.net/forums/t/41425.aspx

"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities