WPF INotifyPropertyChanged for linked read-only properties

后端 未结 7 1322
小鲜肉
小鲜肉 2020-12-30 09:22

I am trying to understand how to update the UI if I have a read-only property that is dependent on another property, so that changes to one property update both UI elements

7条回答
  •  被撕碎了的回忆
    2020-12-30 10:05

    You could simply call

    OnPropertyChanged(this, "bar");
    

    from anywhere in this class...You cold even go like this:

        public raz()
        {
            this.PropertyChanged += new PropertyChangedEventHandler(raz_PropertyChanged);
        }
    
        void raz_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if(e.PropertyName == "foo")
            {
                 onPropertyChanged(this, "bar");
            }
        }
    

提交回复
热议问题