WPF combo box weird problem

2019-07-02 20:46发布

问题:

I am binding a SortedListbox to an WPF combo box. everything was fine. The problem happend when i select the first [only the first] item. The problem is that SelectedValue doesnt change when a new item is selected after selecting first item. Suppose SelectedValue of the first item is '1' and the SelectedValue of third item in the combo is '3'. If i select the first item and then selected the third item. SelectedValue remains'1', when '3' is expected.

Any 1 faced similar problems.

Regards,

John.

回答1:

Maybe you can try to use IsSynchronizedWithCurrentItem on your control.

<ComboBox IsSynchronizedWithCurrentItem="True" />


回答2:

Unless you post the code for the combobox from xaml page, you won't be able to find the reason. Maybe your ComboBox.SelectedValue or ComboBox.SelectedItem isn't defined properly but nothing worthy can be said until code is seen