Fellow coders!
I have an app where ComboBox is bound to the list of EF Core entities. What I found is when I bind it to SelectedItem it will not return the correct item in a disconnected scenario. However, when using both SelectedValue and SelectedItem, it seems to work fine. Is this a good approach? Parent object holds both "int Id" and Navigation Property. So SelectedItem is bound to Navigation Property and SelectedValue to "int Id".
C#:
public Person()
{
int Id {get; set;}
string Name {get; set;}
}
XAML:
<ComboBox
DisplayMemberPath="Name"
SelectedValuePath="Id"
ItemsSource="{Binding People}"
SelectedValue="{Binding SelectedPerson, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
SelectedItem="{Binding SelectedPersonNavigation", UpdateSourceTrigger=PropertyChanged, Mode=OneWay}" />