ObservableCollection PropertyChanged event

后端 未结 4 1126

OK so I want to subclass ObservableCollection to add a property to it. Unfortunately the PropertyChanged event is protected. Basically I want to subcla

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-14 14:40

    I tried to add a new property in

    public class ResultCollection : ObservableCollection
    {
    
            Boolean _val;
            public Boolean Val
            {   
                get
                {   
                    return _val;
                }
                set
                {   
                    _val= value;
                    OnPropertyChanged(new PropertyChangedEventArgs("Val"));
                }
            }
    }
    

    I really didn't notice that PropertyChanged is defined as protected. Finally moved Val property to ViewModel.

提交回复
热议问题