Why can't [INotifyPropertyChanged] be used if something already implements the interface? #465
Replies: 3 comments
-
FWIW: Its always good to show a code example that demonstrates the problem. This ensures everyone is discussing the same detail, and makes it easier to make suggestions. |
Beta Was this translation helpful? Give feedback.
-
As suggested, here is an example of the problem I was experiencing. interface ISomeInterface : INotifyPropertyChanged {
}
[INotifyPropertyChanged]
partial class SomeClass : ISomeInterface {
} In this example, I get the MVVMTK0001 error (on the |
Beta Was this translation helpful? Give feedback.
-
I support this feature request. If it's not possible in general, it would be helpful for me if Microsoft.Maui.Controls.BindableObject would be supported. I know, some hardcore MVVM fans may cry, but there's more than one way to get the job done. Edit: Like https://github.com/canton7/PropertyChanged.SourceGenerator |
Beta Was this translation helpful? Give feedback.
-
So the problem is that I can't use the attribute on a class that already implements the interface and I get the MVVMTK0001 error (among other ones if I try other workarounds) but is this check really necessary?
It prevents me from using my own interfaces (that then have a dependency on INotifyPropertyChanged) which makes it really annoying to use because then I have to structure my code in a specific way which obviously reduces the freedom of using the mvvm toolkit.
I can see why it might have been done so that there are no duplicate implementations of the interface, but surely just the regular C# errors would be enough for someone to realise that they have implemented it themselves as well.
Beta Was this translation helpful? Give feedback.
All reactions