Sometimes we just need a simple combo box that will have predefined items but the selected value must be bound to a property from our View Model. The XAML below is a simple approach to resolve the task:
<combobox>
Width="220"
SelectedValue="{Binding Path=Employee.Gender, Mode=TwoWay}"
SelectedValuePath="Content">
<combobox.items>
<comboboxitem content=" " />
<comboboxitem content="Male" />
<comboboxitem content="Female" />
</combobox.items>
</combobox>
The trick is to set the SelectedValuePath
to the Content
and bind the SelectedValue
.