Wpf combobox binding selecteditem not updating
Then when the combo box box goes to check to make sure your item is in the selection it will find a match.
What seems to be the issue is that the Selected Value/Selected Item is occurring before the Item source is finished loading.
The object is returning the correct object via the get in the property though.
I'm not sure if this is just an issue with the way the Combo Box and MVVM pattern works. I have had similar issues and it was solved by making sure I was implementing IEquatable properly.
It is described here for anyone with the same problem: stackoverflow.com/questions/33739513/… I have noticed that the Selected Index property doesn't cause the same bug.
The reason why it was so hard for me to pin this down is because the collections for the combos populated just fine, when I had my property changed event in my view model.
My example data item doesn't implement INotify Property Changed, but our actual data items do, so they update correctly.
No matter what I do, I cannot get the UI to change when I set the Selected Item property via the View Model.
In my case I was using in complex type (List) as the Item Source and was using a Key Type as the selected value. Selecting a color was possible but it wasnt displayed when the selection closed (although the property was changed!
On the load event, the Key Type was getting set to null. None of the sub elements would get updated when the key changed. ) The fix was overwriting the Equals(object obj) method for the type selected in the Combo Box (Brush), which wasnt simple because Brush is sealed.