ComboBox won't display SelectedValue

Aug 24, 2011 at 11:20 AM

Hi Tony

I’ve come across an issue where in a certain set of circumstances I can’t get a ComboBox to display its SelectedValue. Specifically, it’s where I have a ViewModel based on ViewModelDetailBase and an associated View based on a Page (as opposed to a ChildWindow). There’s no problem with the ComboBox loading its values but try as I might I can’t get it to display the item that it is bound to. Binding seems to be okay: I have used a Test Converter to check that the bound value is being passed in to SelectedValue and the value from the model is being passed in.

Initially of course I thought it was something to do with my project but as a test I’ve taken your SimpleMvvm-Part3-After solution and added a test ViewModel (ViewModelDetailBase based on Product) and a View and set things up to display a ComboBox bound to Model.CategoryID. I get exactly the same result, ie the ComboBox doesn’t display a value.

Can you think of anything I might be doing wrong? Does the binding syntax change if a ChildWindow is not being used? Is there some other code needed to make things work? One big difference of course is that using a Page means that the model can’t be passed in via the ctor and I’m either newing an entity in the ctor or getting the entity to edit via the NavigationHelper technique. I’ve spent literally hours trying to work through this so any nugget would be very welcome. If a look at my altered SimpleMvvm-Part3-After solution would help I can easily zip it up and send it over.

Many thanks!

Cheers - Graham

Aug 25, 2011 at 2:32 PM

Can this and/or this be of any help.

I have succeded in making comboboxes work with this help.


Aug 25, 2011 at 9:55 PM

Hi Kennet

Many thanks for your post. I've looked at lots of posts trying to solve this but somehow missed the post on I implemented ComboBoxEx and hey presto! - all working fine. The fact that ComboBoxes were working in other areas of my app seriously side-tracked me, so hopefully this thread will help somebody else. And hopefully the ComboBox will be fixed in SL5...

Thanks again!

Cheers - Graham