private void DoReload() { if (SelectedObject == null) { Categories = new GridEntryCollection <CategoryItem>(); Properties = new GridEntryCollection <PropertyItem>(); } else { // Collect BrowsableCategoryAttribute items var categoryAttributes = PropertyGridUtils.GetAttributes <BrowsableCategoryAttribute>(SelectedObject); browsableCategories = new List <BrowsableCategoryAttribute>(categoryAttributes); // Collect BrowsablePropertyAttribute items var propertyAttributes = PropertyGridUtils.GetAttributes <BrowsablePropertyAttribute>(SelectedObject); browsableProperties = new List <BrowsablePropertyAttribute>(propertyAttributes); // Collect categories and properties var properties = CollectProperties(currentObjects); // TODO: This needs more elegant implementation var categories = new GridEntryCollection <CategoryItem>(CollectCategories(properties)); if (_categories != null && _categories.Count > 0) { CopyCategoryFrom(_categories, categories); } Categories = categories; //new CategoryCollection(CollectCategories(properties)); Properties = new GridEntryCollection <PropertyItem>(properties); } }
private static void CopyCategoryFrom(GridEntryCollection <CategoryItem> oldValue, IEnumerable <CategoryItem> newValue) { foreach (var category in newValue) { var prev = oldValue[category.Name]; if (prev == null) { continue; } category.IsExpanded = prev.IsExpanded; } }