How is ICollectionViewLiveShaping
implemented for the purpose of filtering? Is it something like:
public ICollectionView WorkersEmployed { get; set;
All you need to do is add a property
in LiveFilteringProperties
for which you want the filter to call on property change and set IsLiveFiltering
to true
for your collection to enable live filtering
.
Make sure PropertyChanged
event gets raised whenever EmployerID
property changes i.e. your Worker
class should implement INotifyPropertyChangedEvent
.
This will work then -
public ICollectionViewLiveShaping WorkersEmployed { get; set; }
ICollectionView workersCV = new CollectionViewSource
{ Source = GameContainer.Game.Workers }.View;
ApplyFilter(workersCV);
WorkersEmployed = workersCV as ICollectionViewLiveShaping;
if (WorkersEmployed.CanChangeLiveFiltering)
{
WorkersEmployed.LiveFilteringProperties.Add("EmployerID");
WorkersEmployed.IsLiveFiltering = true;
}