Replies: 1 comment
-
I am actually too interested in this. I didn't find any other solution other than yours and I don't think there is. It would be nice to support it in existing attribute or to have another Attribute to support collection changes. (e.g. [NotifyCanExecuteChangedFor] -> [NotifyCanExecutePropertyChangedFor] and [NotifyCanExecuteCollectionChangedFor]) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I don't know if this is possible, but say I have a collection and command this like this:
Adding or removing items from the collection does not trigger
NotifyCanExecuteChanged
, because[ObservableProperty]
attribute is only for when the reference to the collection itself is changed (e.g.SelectedItems = new();
).This can be solved by hooking up to the
CollectionChanged
event and calling the relevant things manually:Is there a better way this could be handled? Could the source generators generate this additional bit of code when [ObservableProperty] is used on a collection type?
I'd have a go myself, but I'm not sure where to start with the source generators.
Beta Was this translation helpful? Give feedback.
All reactions