WPF Databinding combobox to a list<string>

Posting my comment back to mark the answer.

My DataContext was set, BUT it was set after InitializeComponent(). I thought that could be the problem. Then I realized that as I am binding through xaml, when the view loads, the binding happens to the property which is empty.

The property gets populated when the view is ready after its loaded (i.e on _presenter.OnViewReady()). Since it's not an observable collection nothing gets added to the combobox. Specifying it from my code behind works, because at that time the data exists in the property.


Assume you have a List<Foo> called Foos in your window / page. Foo has a property Name. Now you set up the binding in XAML as follows:

<ComboBox ItemsSource="{Binding Path=Foos}"
DisplayMemberPath="Name"
SelectedValuePath="Name"
SelectedValue="{Binding Path=Foo}"
/>

This is based on this SO question. Read this (WPF DataBinding overview) as a good foundation for databinding in WPF.