简体   繁体   中英

Property Changed event within class

I got a question about events within classes.

I have a whole load of properties within my class and want to fire an event whenever a property is changed. I want to use the changed properties to calculate a result.

One possible option might be adding a call to every single property-set but this is - for my understanding - too q'n'd.

The common approach to realise this would be to implement the INotitfyPropertyChanged interface and raise the PropertyChanged event in every settter method for the properties where you need it.

Then you implement an event handler which reacts to the event and performs the operations needed.

https://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.110).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM