private Control CreatePropertyControl(ListProperty property) { Type type = property.UnderlyingType; BindListAttribute listAttribute = type.GetCustomAttribute <BindListAttribute>(); listAttribute ??= property.PropertyInfo.GetCustomAttribute <BindListAttribute>(); Control control = null; if (type == typeof(bool)) { control = new TabControlCheckBox(property); } else if (type.IsEnum || listAttribute != null) { control = new TabControlComboBox(property, listAttribute); } else if (typeof(DateTime).IsAssignableFrom(type)) { control = new TabDateTimePicker(property); } else if (!typeof(IList).IsAssignableFrom(type)) { control = new TabControlTextBox(property); } return(control); }
public TabControlComboBox(ListProperty property, BindListAttribute propertyListAttribute) { Property = property; InitializeComponent(); IsEnabled = property.Editable; MaxWidth = TabControlParams.ControlMaxWidth; Type type = property.UnderlyingType; if (propertyListAttribute != null) { PropertyInfo propertyInfo = property.Object.GetType().GetProperty(propertyListAttribute.Name); Items = propertyInfo.GetValue(property.Object) as IEnumerable; } else { var values = type.GetEnumValues(); Items = values; } Bind(property.Object, property.PropertyInfo.Name); }