How to let a parent class know about a change in its children?

后端 未结 5 1176
走了就别回头了
走了就别回头了 2021-02-09 00:28

This is an example code:

public class MyParent : INotifyPropertyChanged
{
    List MyChildren;

    public bool IsChanged
    {
        get
               


        
5条回答
  •  失恋的感觉
    2021-02-09 01:21

    I'm not quite familiar with C++ code, but this sounds much like the "observer pattern" (Wikipedia, another good page for OO design. In simple words, any instance should raise an event whenever it has changed, and any other instance which holds a reference to it may catch this event and react appropriately.

提交回复
热议问题