WPF Binding without path with converter, update

后端 未结 3 2077

I have a binding without path using a converter. This is because the converter will use many properties of the object to build the text for the tooltip. But when one property ch

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-21 00:23

    If you implement the INotifyPropertyChange interface on a data type class, that takes care of notifying for changes to the class properties. If you implement the INotifyPropertyChange interface on a view model class that has a property of the type of your class, then that takes care of notifying for changes to that property, which in this case is the whole object.


    UPDATE >>>

    Right... I believe that you have a property of type ObservableCollection. If you add a PropertyChanged handler to each of the items...:

    foreach (Bar item in YourCollectionProperty) item.PropertyChanged += 
    Item_PropertyChanged;
    

    ... then you can do this:

    private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        NotifyPropertyChanged("YourCollectionProperty");
    }
    

提交回复
热议问题