using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Windows.Data; namespace Microsoft.Windows.Controls.PropertyGrid { public class PropertyCollection : ObservableCollection { public PropertyCollection() { } public PropertyCollection(List list) : base(list) { } public PropertyCollection(IEnumerable collection) : base(collection) { } private ICollectionView GetDefaultView() { return CollectionViewSource.GetDefaultView(this); } public void GroupBy(string name) { GetDefaultView().GroupDescriptions.Add(new PropertyGroupDescription(name)); } public void SortBy(string name, ListSortDirection sortDirection) { GetDefaultView().SortDescriptions.Add(new SortDescription(name, sortDirection)); } public void Filter(string text) { GetDefaultView().Filter = (item) => { var property = item as PropertyItem; return property.Name.ToLower().StartsWith(text.ToLower()); }; } } }