我有一个Layersbinded 列表TreeView,每个实例都有一个列表Effects.我通过HierarchicalDataTemplate显示它们,它工作得很好,但我正在尝试使用它们进行排序SortDescriptions.
我不知道如何在xaml中执行此操作,但这样做只对第一级别的项目进行排序,而不是子项目:
ICollectionView view = CollectionViewSource.GetDefaultView ( treeView1.ItemsSource );
view.SortDescriptions.Add ( new SortDescription ( "Name", ListSortDirection.Ascending ) );
Run Code Online (Sandbox Code Playgroud)
我试图先将它们排序.Color,然后依次排序.Name.
有任何想法吗?
编辑:我添加了这段代码:
<Window.Resources>
<CollectionViewSource x:Key="SortedLayers" Source="{Binding AllLayers}">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="Color" />
<scm:SortDescription PropertyName="Name" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)
但这仍然只适用于第一级层次结构.如何为每个图层指定它.影响集合?