I have a ComboBox with an ItemsSource bound to an ObservableCollection<T>. This ComboBox is part of a detail view which updates dynamically based on a selected master item.
The issue I’m having is that the ComboBox SelectedItem does not persist after the master item is changed. If I click away and then back to the item the selection in the ComboBox is cleared.
Any ideas why this is happening?
Maybe there are better ways to do this but this approach seemed to work:
The
ObservableCollection<T>had to be a property in the the source object I am binding to. Previously I was using a{Binding RelativeSource={RelativeSource AncestorType=VisualParent}expression that was getting the source property from a parent in the visual tree.If anyone has insight into why this was the case feel free to leave comment on this for my own (and others) learning.