private static int GetSelectedValueAsInt(ComboBox comboBox) { return comboBox.SelectedItem != null ? ((KeyValuePair<string, int>)comboBox.SelectedItem).Value : -1; }