Both Fody's PropertyChanged and Josh Smith's PropertyObserver are two great packages/patterns to use in WPF development. However, they don't seem to be able to be used together.
At compile time, it seems that the class that I'm trying to observe needs to explicitly implement INotifyPropertyChanged (instead of just adding the Fody ImplementPropertyChanged tag on the class).
The type 'MyViewModel' cannot be used as type parameter 'TPropertySource' in the generic type or method 'PropertyObserver'. There is no implicit reference conversion from 'MyViewModel' to 'System.ComponentModel.INotifyPropertyChanged'
Am I missing something? Does someone have a clever solution?
As the Fody.PropertyChanged documentation states:
All classes that do not have [ImplementPropertyChanged] but still have INotifyPropertyChanged will have notification code injected into property sets.
So manually implement INotifyPropertyChanged
on your class (no choice here, since PropertyObserver is expecting a type implementing this interface), and you'll still have the the calls to PropertyChanged
injected in your properties by Fody.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With