private ComboBox GeneratePropertyComboBox() { ComboBox comboBox = new ComboBox(); comboBox.Style = Application.Current.FindResource("ComboBoxFlatStyle") as Style; comboBox.DisplayMemberPath = "Key"; foreach (var value in mValues) { comboBox.Items.Add(value); } foreach (var item in comboBox.Items) { if (((KeyValuePair <string, object>)item).Value.GetType() == TargetProperty.GetType()) { comboBox.SelectedItem = item; break; } } comboBox.SelectionChanged += OnPropertyChanged; return(comboBox); }