0

I have a ReactiveObject ViewModel that contains an IObservableCollection and a regular property that raises INPC when it is modified (ie, vanilla WPF).

I want to implement an ObservableForPropertyHelper backed read-only that will re-evaluate whenever the regular property changes, or the collection changes (raises its CollectionChanged) event.

I know I can implement this using WhenAnyValue for the regular property, FromEventPattern to create an observable for the collectionchanged event, and then stitching them together with a CombineLatest. My question is - is there a less god-awful way to do this? Is there a built in ReactiveUI functionality that will help me achieve this?

Andrew
  • 1,482
  • 9
  • 16
  • 1
    Please provide the "god-awful" implementation in your code and then we can try to improve it for you. Right now it's difficult to determine what you actually want and a god-awful amount of work for us to try guess what you want. Please make it easy for us to answer you. – Enigmativity Aug 27 '15 at 04:09

1 Answers1

0

You could swap the ObservableCollection for ReactiveUI's ReactiveCollection which exposes an IObservable for when the collection changes.

You could also use ReactiveUI's ObservableForProperty instead of WhenAny, which will be a little more succinct as you are only observing 1 property.

Other than that, what you have described is how I would do it.

Chris
  • 471
  • 3
  • 8