Same ItemSource, but has another View each listboxes
Here is my situation:
A ObservableCollection is exist and a series of listbox in a window has showing their bound data.
public Records myRecents;
//...
this.lbToday.ItemsSource = myRecents;
this.lbYesterday.ItemsSource = myRecents;
this.lbBefore2Days.ItemsSource = myRecents;
this.lbLast7Days.ItemsSource = myRecents;
this.lbLast30Days.ItemsSource = myRecents;
And now, I want to applie each listboxes to different filtered view.
this.lbToday.Items.Filter = delega开发者_StackOverflowte(object item)
{
return ((RecordItem)item).IsToday();
};
A problem is, the filter applied all listboxes which using same itemsource.(in this case, the 'myRecents')
How can I applying differ filterings each listbox?
Use different ListCollectionViews
for each one of your ListBoxes
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);
精彩评论