The OnPropertyChanged() method would need to use reflection to get the value. also the passed name is just specified in an attribute, it does not specify an actual underlying property (or object if nested).
I am using the MVVM pattern and I want to get the value of the property in the OnPropertyChanged event
I want to get the value of the property in the OnPropertyChanged event. I would rather not use reflection.
2 answers
Sort by: Most helpful
-
-
Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 41,601 Reputation points Microsoft Vendor
2024-07-12T02:52:33.5933333+00:00 Hello,
It is unfeasible to get the value in the
PropertyChanged
event. The reason is as follows.In the
OnPropertyChanged
event, it serves to notify other components that the value of this property has changed. Therefore, in this event you will only find the property PropertyName and not the value. when using this method, it is common to manually assign the value in the setter method and then call this method. You could refer to the following documentation.Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.