我在这里关注这个链接:http: //jacobmsaylor.com/ ?p=1270
但我遇到了问题,试图对其进行调整
<ListBox Name="PageList_ListBox" MouseDoubleClick="PageList_ListBox_OnMouseDoubleClick"
Background="#FFC9C9C9" Margin="0,5,0,0" ItemsSource="{Binding PageCollection, ElementName=This}">
.
public static ObservableCollection<MLBPage> _PageCollection = new ObservableCollection<MLBPage>();
public static ObservableCollection<MLBPage> PageCollection
{
get { return _PageCollection; }
}
public ICollectionView _PageCollectionView { get; set; }
_PageCollectionView = CollectionViewSource.GetDefaultView(_PageCollection);
private bool FilterLeadersList(object item)
{
MLBPage page = item as MLBPage;
if (page.templateName.Contains("Leaders List"))
{
return true;
}
else
{
return false;
}
}
我的 MLBPage 对象有 2 种类型......其中“templateName”可以是“Leaders List”或“Leader Headshots”......现在当我通过添加到按钮来过滤集合时:
_PageCollectionView.Filter = FilterLeadersList;
整个集合只是过滤器(绑定到列表框的 _PageCollection 变为空白),而不仅仅是名称中包含“Leaders List”的项目......
关于如何修改它以使其工作的任何帮助?