private void createNewEnumRow(PropertyInfo prop, int row, PropertyFieldAttribute attr) { if (!uiElementMap.ContainsKey(prop.Name)) { gridAddRowDef(); gridAddTitle(prop); var cb = new ComboBox(); Type type = prop.PropertyType; if (attr.EnumType != null) { type = attr.EnumType; } if (!addValueInComboBox(cb, type)) { return; } cb.Margin = new Thickness(0, 2, 2, 0); cb.BorderThickness = new Thickness(0); Grid.SetColumn(cb, 1); Grid.SetRow(cb, _panelParent.RowDefinitions.Count - 1); cb.Tag = prop; int propValue = (int)prop.GetValue(_selectedObject); string text = EnumTools.GetTextByValue(propValue, type); cb.SelectedItem = text; cb.SelectionChanged += new SelectionChangedEventHandler((object sender, SelectionChangedEventArgs e) => { int enumValue = EnumTools.GetEnumValue(cb.SelectedValue.ToString(), type); prop.SetValue(_selectedObject, EnumTools.Int2Enum(enumValue, type)); }); var template = (ControlTemplate)_View.Resources["validationErrorTemplate"]; Validation.SetErrorTemplate(cb, template); uiElementMap[prop.Name] = cb; _panelParent.Children.Add(cb); gridAddEnd(); } }