private void LoggingLevelBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { var comboBox = sender as ComboBox; string comboBoxSelectedItem = comboBox.SelectedItem as string; var loggingLevelValues = Enum.GetValues(typeof(ErrorLogging.LoggingLevel)); foreach (ErrorLogging.LoggingLevel loggingLevel in loggingLevelValues) { if (loggingLevel.ToString() == comboBoxSelectedItem) { ErrorLogging.SetLoggingDisplayLevel(loggingLevel); return; } } }