SelectedIndex of combobox not updating correctly using databinding.
Posted
by Matthijs Wessels
on Stack Overflow
See other posts from Stack Overflow
or by Matthijs Wessels
Published on 2010-03-24T15:29:02Z
Indexed on
2010/03/24
15:33 UTC
Read the original article
Hit count: 403
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?
© Stack Overflow or respective owner