private static FrameworkElement ExtractList(DisplayOption option) { var drop = new Expander { Margin = new Thickness(5), Header = option.ReadableName }; var listType = option.PropertyType.GetGenericArguments()[0]; FrameworkElement ctrl; if (listType == typeof(Item) || listType == typeof(Attribute) || listType == typeof(VillagerRecipe) || listType == typeof(PotionEffect) || listType == typeof(BookPage) || listType == typeof(Enchantment) || listType == typeof(MapDecoration) || listType == typeof(BlockType) || listType == typeof(BannerPattern) || listType == typeof(JsonTextElement)) { if (!option.FixedSize || (option.Minimum == null || option.Maximum == null)) { var sPanel = new ItemListControl { SlotDescription = { Text = option.Description }, AddRemoveButtons = { Visibility = option.FixedSize ? Visibility.Collapsed : Visibility.Visible } }; sPanel.SetBinding(FrameworkElement.DataContextProperty, new Binding(option.PropertyName)); ctrl = sPanel; } else { var invGrid = new InventoryControl { InvWidth = (int)option.Minimum, InvHeight = (int)option.Maximum, HorizontalAlignment = HorizontalAlignment.Center }; invGrid.SetBinding(FrameworkElement.DataContextProperty, new Binding(option.PropertyName)); ctrl = invGrid; } } else { // ReSharper disable once UseObjectOrCollectionInitializer var ctrl2 = new DataGrid { Margin = new Thickness(3), AutoGenerateColumns = true, CanUserAddRows = !option.FixedSize, MinHeight = 50 }; ctrl2.AutoGeneratingColumn += (sender1, e1) => { var displayName = PropertyHelpers.GetPropertyDisplayName(e1.PropertyDescriptor); if (e1.PropertyType == typeof(string)) { ((DataGridTextColumn)e1.Column).EditingElementStyle = (Style)Application.Current.Resources["DataGridTextColumnStyle"]; } if (!string.IsNullOrEmpty(displayName)) { e1.Column.Header = displayName; } else { e1.Cancel = true; } }; if (option.DataGridRowHeaderPath != null) { var rowHeaderStyle = new Style(typeof(DataGridRowHeader)); rowHeaderStyle.Setters.Add(new Setter(ContentControl.ContentProperty, new Binding(option.DataGridRowHeaderPath))); ctrl2.RowHeaderStyle = rowHeaderStyle; } ctrl2.Margin = new Thickness(15, 0, 0, 0); ctrl = ctrl2; ctrl.SetBinding(ItemsControl.ItemsSourceProperty, new Binding(option.PropertyName)); } drop.Content = ctrl; drop.SetValue(Grid.ColumnSpanProperty, 2); return(drop); }