CommunityToolkit / MVVM-Samples

Sample repo for MVVM package
Other
1.11k stars 222 forks source link

[QUESTION] How to do something when the value of a property changes? #121

Closed ComptonAlvaro closed 1 year ago

ComptonAlvaro commented 1 year ago

I would like to do something when a bool property changes the value when in the view the user chages the value.

I have this:

[ObservableProperty]
bool _myProperty;

In somewhere, I don't remember where, I have read I could define a method which name is On[PropertyName] or On[PropertyName]Changed or somethink like that, that would be execute when the value of the property changes.

I have probe some variations of this, but all of them fail.

I am wrong and I misunderstood the examples that I have read?

Thanks.

Sergio0694 commented 1 year ago

There's several options, depending on what you need. You can find docs and more examples on MS Learn 🙂

ComptonAlvaro commented 1 year ago

Thanks, it was I am looking for.