private void Init() { var detail = this; foreach (var propertyInfo in TypeObj.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance)) { detail.Children.Add(new TextBlock { Text = SeparateCapitalWords(propertyInfo.Name) }); FrameworkElement element; var binding = new Binding(propertyInfo.Name); if (propertyInfo.CanWrite) { binding.Mode = BindingMode.TwoWay; if (typeof(DateTime).IsAssignableFrom(propertyInfo.PropertyType)) { var dtp = new DatePicker(); dtp.SetBinding(DatePicker.SelectedDateProperty, binding); element = new CoverControl { Control = dtp, Name = propertyInfo.Name }; } else if (typeof(Enum).IsAssignableFrom(propertyInfo.PropertyType)) { var cb = new ComboBox(); cb.SetBinding(Selector.SelectedItemProperty, binding); var propertyInfo1 = propertyInfo; Utilities.FillEnums(cb, propertyInfo1.PropertyType); element = new CoverControl { Control = cb, Name = propertyInfo.Name }; } else if (typeof(Persistent).IsAssignableFrom(propertyInfo.PropertyType)) { var cb = new ComboBox(); cb.SetBinding(Selector.SelectedItemProperty, binding); var propertyInfo1 = propertyInfo; dropdowns[cb] = propertyInfo1.PropertyType; element = new CoverControl { Control = cb, Name = propertyInfo.Name }; } else { var tb = new TextBox(); tb.SetBinding(TextBox.TextProperty, binding); element = new CoverControl { Control = tb, Name = propertyInfo.Name }; } } else { binding.Mode = BindingMode.OneWay; var tb = new TextBlock(); tb.SetBinding(TextBlock.TextProperty, binding); element = tb; } detail.Children.Add(element); } var grid = new Grid { Margin = new Thickness(0, 50, 0, 0) }; grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); var b = new Button { Content = "Delete" }; b.Click += DeleteOnClick; b.SetValue(Grid.ColumnProperty, 2); grid.Children.Add(b); detail.Children.Add(grid); }