Is it possible to filter an ObservableCollection
within a property? I have tried variations of the following:
public ObservableCollection<Worker> Workers
{
get { return DataManager.Data.MasterWorkerList.Where(w => w.Known == true); }
set { DataManager.Data.MasterWorkerList = value; }
}
I get an error that says:
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'System.Collections.ObjectModel.ObservableCollection'. An explicit conversion exists (are you missing a cast?)
When I cast the type, the program compiles, but I get an InvalidCastException
saying
Unable to cast object of type 'WhereEnumerableIterator
1[AoW.Models.Worker]' to type 'System.Collections.ObjectModel.ObservableCollection
1[AoW.Models.Worker]'
Is it possible to filter this way? If so, what am I missing?