This is a prime example of why WPF developers should use the MVVM design pattern. By relying on SelectionChanged events to control the flow of your code, you're losing your own control over what should happen and are resorting to having to know how an event is being triggered so that you can respond. That's reactive, not pro-active. As a developer, you should always know what can and will affect your code flow.
Rather, set your WPF page or control's DataContext to a viewmodel class that wraps your model and bind your combobox to the ViewModel properties, specifically SelectedItem in this case. This will simplify your coding immensely.
ViewModel
public class ViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public ObservableCollection<string> Names = new ObservableCollection<string>();
private string _selectedName;
private YourModel _model;
public ViewModel(YourModel model)
{
_model = model;
}
public string SelectedName
{
get { return _model.SelectedName; }
set
{
_model.SelectedName = value;
OnPropertyChanged();
}
}
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
XAML
<ComboBox ItemsSource="{Binding Names}" SelectedItem="{Binding SelectedName}" />