SelectedIndex of combobox not updating correctly using databinding.
- by Matthijs Wessels
I have a ComboBox:
<ComboBox Name="iComponentFieldComboBox" SelectedIndex="{Binding ComponentFieldSelectedIndex, Mode=TwoWay}" Height="23" Margin="132,0,280,38" VerticalAlignment="Bottom">
<ComboBoxItem Name="item1">item1</ComboBoxItem>
<ComboBoxItem Name="item2">item2</ComboBoxItem>
<ComboBoxItem Name="item3">item3</ComboBoxItem>
</ComboBox>
When I start my WPF and set the ComponentFieldSelectedIndex property of my ViewModel in my code, nothing happens. But after I have selected an item in the combobox, then suddenly setting ComponentFieldSelectedIndex does work.
for example:
start app.
click button that sets ComponentFieldSelectedIndex to 1.
selected item doesn't change to item2.
select item3 in combo box.
click button that sets ComponentFieldSelectedIndex to 1.
selected item does change to item2.
Does anyone have an idea what could be causing this?