Subscribe to INotifyPropertyChanged for nested (child) objects

后端 未结 6 1274
执念已碎
执念已碎 2020-12-04 22:05

I\'m looking for a clean and elegant solution to handle the INotifyPropertyChanged event of nested (child) objects. Example code:

<         


        
6条回答
  •  旧时难觅i
    2020-12-04 22:53

    Interesting solution Thomas.

    I found another solution. It's called Propagator design pattern. You can find more on the web (e.g. on CodeProject: Propagator in C# - An Alternative to the Observer Design Pattern).

    Basically, it's a pattern for updating objects in a dependency network. It is very useful when state changes need to be pushed through a network of objects. A state change is represented by an object itself which travels through the network of Propagators. By encapsulating the state change as an object, the Propagators become loosely coupled.

    A class diagram of the re-usable Propagator classes:

    A class diagram of the re-usable Propagator classes

    Read more on CodeProject.

提交回复
热议问题