我正在写windows phone 8.1通用应用程序,并且主要应用程序控件是Pivot
,只有少量数据。在透视项目中是包含TestItems的ListViews。我想通过IsRead属性筛选一个列表中的项目。是否有可能过滤主要收藏而不保留2个收藏?如果我知道的话,CollectionViewSource
不支持在通用应用上过滤排序。但保持(和同步更改)两个集合看起来不是个好主意。Windows Phone 8.1上的ObservableCollection过滤通用
编辑: 我已经使用了ObservableCollection,因为项目列表可能会在后台更新。可能从原始问题中不清楚。
class TestItem : ModelBase
{
private bool isRead;
public bool IsRead
{
get { return isRead; }
set
{
isRead = value;
NotifyPropertyChanged();
}
}
private string name;
public string Name
{
get { return name; }
set
{
name = value;
NotifyPropertyChanged();
}
}
}
class MainViewModel : INotifyPropertyChanged
{
public MainViewModel()
{
Items = new ObservableCollection<TestItem>();
}
public ObservableCollection<TestItem> Items { get; private set; }
public ObservableCollection<TestItem> ItemsRead { get; private set; } // key point
private void RefreshItems()
{
// data manipulation - on both collections?
}
// ...
}
但问题是,该视图不会通知有关更改。 – Fanda