Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 相同的ItemSource,但每个列表框都有另一个视图_C#_Wpf_Data Binding_Listbox - Fatal编程技术网

C# 相同的ItemSource,但每个列表框都有另一个视图

C# 相同的ItemSource,但每个列表框都有另一个视图,c#,wpf,data-binding,listbox,C#,Wpf,Data Binding,Listbox,以下是我的情况: 存在ObservableCollection,并且窗口中的一系列列表框显示了它们的绑定数据 public Records myRecents; //... this.lbToday.ItemsSource = myRecents; this.lbYesterday.ItemsSource = myRecents; this.lbBefore2Days.ItemsSource = myRecents; this.lbLast7Days.ItemsSource = myRece

以下是我的情况:

存在ObservableCollection,并且窗口中的一系列列表框显示了它们的绑定数据

public Records myRecents;

//...

this.lbToday.ItemsSource = myRecents;
this.lbYesterday.ItemsSource = myRecents;
this.lbBefore2Days.ItemsSource = myRecents;
this.lbLast7Days.ItemsSource = myRecents;
this.lbLast30Days.ItemsSource = myRecents;
现在,我想将每个列表框应用于不同的过滤视图

this.lbToday.Items.Filter = delegate(object item)
{
    return ((RecordItem)item).IsToday();
};
一个问题是,过滤器应用了使用相同itemsource的所有列表框 "我的近况")


如何对每个列表框应用不同的过滤器?

对每个列表框使用不同的
ListCollectionView

this.lbToday.ItemsSource = new ListCollectionView(myRecents); 
this.lbYesterday.ItemsSource = new ListCollectionView(myRecents); 
this.lbBefore2Days.ItemsSource = new ListCollectionView(myRecents);
this.lbLast7Days.ItemsSource = new ListCollectionView(myRecents); 
this.lbLast30Days.ItemsSource = new ListCollectionView(myRecents);