有没有办法可以过滤CollectionViewSource
仅显示游戏ItemsSource
哪个“标题”包含“searchString”?
In my PosterView
我有这个CVS:
<CollectionViewSource x:Key="GameListCVS"
Source="{Binding PosterView}"
Filter="GameSearchFilter">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="Title" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
还有这个ItemsControl
<ItemsControl x:Name="gameListView"
ItemsSource="{Binding Source={StaticResource GameListCVS}}">
我的 MainWindow.xaml 包含搜索框,它可以成功地将 searchString (包含搜索框中内容的字符串)传递给PosterView
.
PosterView
绑定实际上(令人困惑的是,我知道),一个ObservableCollection
public ObservableCollection<GameList> PosterView { get; set; }
以下是如何将游戏添加到ObservableCollection
games.Add(new GameList
{
Title = columns[0],
Genre = columns[1],
Path = columns[2],
Link = columns[3],
Icon = columns[4],
Poster = columns[5],
Banner = columns[6],
Guid = columns[7]
});