Closed kkneip closed 6 years ago
I'm pretty sure that the AutoRefresh() operator will give you updates whenever an underlying property changes.
Check out the examples in the snippets repo.
https://github.com/RolandPheasant/DynamicData.Snippets/tree/master/DynamicData.Snippets/AutoRefresh
Thanks modplug,
unfortunately it's not working on my side. I'll try to get the snippet working to see what's going wrong.
Additional ideas are much appreciated.
I'll checked out "AutoRefresh" which works fine on sorting and filtering. But seems not to influence aggregation.
Any ideas how to get it working, though?
The aggregation operators were intentionally written to be light weight and do not maintain any state. That is why Refresh / AutoRefresh have no effect.
However there is an easy workaround. Use ToCollection()
and use linq to objects to sum the items
myDataSource.ToCollection().Select(items = items.Select(x=>x.Price).Sum());
You will still need to use Refresh / AutoRefresh to trigger on notify property change.
Please let me know if that works.
Thanks a lot, Roland!
Now it's behaving as expected!
I'll close this one then.
If you want an invite to the Slack forum send me your email address to roland@dynamic-data.org and I will invite you - it's easier to ask questions there,
Hi,
I have a question regarding a SourceCache containing objects of instances that implement INotifyPropertyChanged. I'd like to use aggregate function to sum up a decimal property called "Price". I expect the sum to change if the "Price" of one included object instances in the cache changes. But it doesn't!
What am I doing wrong? Does DynamicData not support a scenario like this? Running "Refresh" on an object seems not to have any effect, either.
Many thanks in advance!