最近在看關於Mindscape的 WPF Elements這款界面控件產品,界面效果挺炫,本人比較喜歡它的儀表盤的效果···· html
在Mindscape WPF Elements中時如何實現排序、過濾和分組的呢,今天就來分享一下: node
網格屬性能夠按照如下方式來進行設置: 工具
經過設置一個合適的IComparer排序屬性: spa
<ms:PropertyGrid Sorting='{x:Static ms:PropertySorting.ByHumanName}'/>
經過設置的BindingView屬性默認視圖的CustomSort屬性。 code
經過應用SortDescription到BindingView屬性的默認視圖,以下: htm
屬性網格排序(程序): 排序
SortDescription alphabetical = new SortDescription("Node.HumanName", ListSortDirection.Ascending); ICollectionView view = CollectionViewSource.GetDefaultView(PropertyGrid1.BindingView); view.SortDescriptions.Add(alphabetical); 若是網格的一個實例包含擴展節點,排序描述不傳播到子節點(但自定義排序會),若是使用的是SortDescriptions來進行子節點排序, 在BindingView collection中定位父節點,並應用一個SortDescription到子屬性的默認視圖。
網格屬性能夠經過設置BindingView屬性的默認視圖的過濾屬性來過濾,以下所示: ip
ICollectionView view = CollectionViewSource.GetDefaultView(PropertyGrid1.BindingView); view.Filter = delegate(object obj) { Node node = ((PropertyGridRow)obj).Node; return node.Children.Count == 0; };
屬性能夠按照下面的方法來進行分組: get
經過設置分組屬性到一個合適的GroupDescription,分組屬性包含了一個預約義的對於按狀況分組的GroupDescription。 產品
分組屬性(聲明):
<ms:PropertyGrid Grouping='{x:Static ms:PropertyGrouping.ByCategory}'/>
經過應用一個GroupDescription到綁定窗口屬性的默認視圖,以下所示:
分組屬性(程序):
PropertyGroupDescription byCategory = new PropertyGroupDescription("Node", new NodeToCategoryConverter());
ICollectionView view = CollectionViewSource.GetDefaultView(PropertyGrid1.BindingView);
view.GroupDescriptions.Add(byCategory);
屬性網格控件選擇性的用命令顯示工具欄,好比對於按字母順序排序,或按照類別分組(使用CategoryAttribute),或是搜索過濾設備