【发布时间】:2016-05-23 13:29:40
【问题描述】:
我想在我的 ObservableCollection 上使用 linq 创建一个查询,但 T 的尝试方式并没有真正奏效。
我有一个模型Entry,它有{note, information, isActive} 作为参数。所以我现在想简单地获取所有Entries isActive 为真的地方。我不在我的数据提供者上使用它(一旦数据被加载),因为我需要将每个条目加载到程序中。
所以我想在我的条目 ObservableCollection 中覆盖 getter:
public ObservableCollection<Note> _entries { get; set; }
public ObservableCollection<Note> entries
{
get
{
return new ObservableCollection<Note>(from entry in this._entries
where entry.isActive == true
select entry);
}
set { this._entries = value; }
}
但你可能猜到这行不通。
问候
【问题讨论】: