This is a migrated thread and some comments may be shown as answers.

SelectedValue not working?

1 Answer 85 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rob Ainscough
Top achievements
Rank 1
Rob Ainscough asked on 31 Aug 2012, 02:12 AM

I seem unable to get SelectedValue binding (to object) to work consistantly.

I've read a million and one threads of people have similar problems and have tried all the possible solutions.  Even ones that suggest I re-arrange the order of my XAML making sure ItemsSource if first.  I've tried Microsoft's, both will not work.   I've checked the Collection values and everything to make sure there is a valid match ... nothing seems to work?

I'm doing a standard Lookup type ComboBox where I bind on SelectedValue rather than SelectedItem as my source object is not the same as the Lookup objects I populate the ComboBox with.

What's really frustrating is that I'm not getting ANY errors on Binding, my ComboBox will populate with values but I can't get them to have a SelectedValue (shows up blank).  SelectedItem works, SelectedIndex works, but SelectedValue does not.

Biggest problem I have is that I don't get any errors, there's no place for me to go to try and figure out why this just doesn't work.  And what's even more frustrating is that it sometimes ONE ComboBox will work while the other's will not.

Any hints or suggestions are appreciated.

Thanks, Rob.

1 Answer, 1 is accepted

Sort by
0
Rob Ainscough
Top achievements
Rank 1
answered on 31 Aug 2012, 09:38 PM
UPDATE: Found the solution, it was my fault, sorta.  I was setting SelectedValue = value of type Long where the ComboBox object SelectedValuePath was of type Integer.

Oddly this didn't trigger any Binding errors so debugging this was much more involved that is probably should have been.

Rob
Tags
ComboBox
Asked by
Rob Ainscough
Top achievements
Rank 1
Answers by
Rob Ainscough
Top achievements
Rank 1
Share this question
or