Implementing INotifyPropertyChanged - does a better way exist?

前端 未结 30 2608
感情败类
感情败类 2020-11-21 05:23

Microsoft should have implemented something snappy for INotifyPropertyChanged, like in the automatic properties, just specify {get; set; notify;} I

30条回答
  •  粉色の甜心
    2020-11-21 05:32

    => here my solution with the following features

     public ResourceStatus Status
     {
         get { return _status; }
         set
         {
             _status = value;
             Notify(Npcea.Status,Npcea.Comments);
         }
     }
    
    1. no refelction
    2. short notation
    3. no magic string in your business code
    4. Reusability of PropertyChangedEventArgs across application
    5. Possibility to notify multiple properties in one statement

提交回复
热议问题