我正在尝试从 ICollectionView CurrentItem 的属性(相关表 1..Many)在 XAML 中创建 CollectionViewSource,但出现此错误:“System.Windows.Data.BindingListCollectionView”视图不支持排序。
在我的虚拟机中,我有 ICollectionView,它是 UserControls 的 DataContext。
public ICollectionView Clients
客户端有 Loans 属性,这是我想绑定到列表框的。如果我只绑定到 CurrentItem 的属性,它就可以工作:
ItemsSource="{Binding Clients/Loans}"
但我的问题是排序。我想按属性对贷款进行排序,因此我尝试从该列表中创建一个 CollectionViewSource,但随后出现上述错误。
<Grid.Resources>
<CollectionViewSource Source="{Binding Clients/Loans}" x:Key="loan_cv">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="CreatedDate" Direction="Descending" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</Grid.Resources>
这在 XAML 中是否可能而不在 VM 中创建新属性?