Is there any way to automatically update a filter on an ICollectionView
without having to call Refresh()
when a relevant change has been made?
I have the following:
[Notify]
public ICollectionView Workers { get; set; }
The [Notify] attribute in this property just implements INotifyPropertyChanged
but it doesn't seem to be doing anything in this situation.
Workers = new CollectionViewSource { Source = DataManager.Data.Workers }.View;
Workers.Filter = w =>
{
Worker worker = w as Worker;
if (w == null)
return false;
return worker.Employer == this;
};
In XAML:
<TextBlock x:Name="WorkersTextBlock"
DataContext="{Binding PlayerGuild}"
FontFamily="Pericles"
Text="{Binding Workers.Count,
StringFormat=Workers : {0},
FallbackValue=Workers : 99}" />
Update: It looks like using ICollectionView
is going to be necessary for me, so I'd like to revisit this topic. I'm adding a bounty to this question, the recipient of which will be any person who can provide some insight on how to implement a 'hands-off' ICollectionView
that doesn't need to be manually refreshed. At this point I'm open to any ideas.