C# 在代码隐藏中创建CollectionViewSource
我的xaml中有这个代码C# 在代码隐藏中创建CollectionViewSource,c#,wpf,C#,Wpf,我的xaml中有这个代码 <local:MyDataSource x:Key="MyData" /> <CollectionViewSource x:Key="ViewSource" Source="{Binding Source={StaticResource MyData}, Path=Summaries}"> <CollectionViewSource.GroupDescriptions> <Prop
<local:MyDataSource x:Key="MyData" />
<CollectionViewSource x:Key="ViewSource" Source="{Binding Source={StaticResource MyData}, Path=Summaries}">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="Name" />
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
我想转移到我的代码后面
MyDataSource
是一个公共类,我已经有了。它包含一个集合,该集合应填充CollectionViewSource
,以便将其绑定到listView
我已经找了一段时间的教程或什么的,但没有找到任何东西
var collView = CollectionViewSource.GetDefaultView(MyData.Summaries);
collView.GroupDescriptions.Add(new PropertyGroupDescription("Name"));
您的摘要集合必须是
IEnumerable or IListSource