Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

In WPF, how do you bind a ComboBox to an observable collection and selected item?

$
0
0

In my VM I have an observable collection of strings. This is bound to the ComboBox's ItemsSource and this works just fine, the ComboBox's dropdown list is populated with the string. However, I'm not able to bind the ComboBox's selected item to a string property in the VM. I've tried SelectedValue and SelectedItem but they don't seem to update anything in the VM. The SelectedIndex, on the other hand, does get sent to the VM so, if worse comes to worse, I can use this index to programmatically set the selected string property in the VM but it seems like there should be some way to bind the selected item directly. Suggestions?


Richard Lewis Haggard


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>