CommunityToolkit / dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin
Other
2.8k stars 277 forks source link

Discussion on Requirements and Solutions for Unified Monitoring of Attribute Value Changes #894

Open lintao185 opened 6 days ago

lintao185 commented 6 days ago

Overview

In actual projects, there is often a requirement to record the old and new values of an attribute when its value changes (e.g., monitoring personnel changing parameters in the industrial field). In CommunityToolkit.MVVM, each property has its own OnXXXChanged(oldValue, newValue) method. However, this means I need to write n such functions to achieve the above functionality, which is not ideal. Is it possible to add a callback OnPropertyValueChanged(propertyName,oldValue, newValue)?

API breakdown

OnPropertyValueChanged(propertyName,oldValue, newValue)

Usage example

Not

Breaking change?

No

Alternatives

Not

Additional context

No response

Help us help you

No, just wanted to propose this