c# - Why is WPF not updating on INotifyPropertyChanged? -
i implementing inotifypropertychanged
implementing same interfaces , passing calls observablecollection`1
:
class wrappedobservablecollection<telement> : inotifypropertychanged, inotifycollectionchanged //, ...others { private readonly observablecollection<telement> baselist; public wrappedobservablecollection(observablecollection<telement> baselist) { contract.requires(baselist != null); this.baselist = baselist; } #region wrapping of baselist public event propertychangedeventhandler propertychanged { add { ((inotifypropertychanged)baselist).propertychanged += value; } remove { ((inotifypropertychanged)baselist).propertychanged -= value; } } #endregion }
this works fine, when bind .count
property, ui never updates. suspect wrong implementation of inotifypropertychanged
have verified propertychanged.add
called, , event raised when property being changed.
passing .add
call internal list insufficient wpf uses sender
parameter of event determine bindings need updated. use following wrap inotifypropertychanged
while updating sender
:
class wrappedobservablecollection<telement> : inotifypropertychanged, inotifycollectionchanged //, ...others { private readonly observablecollection<telement> baselist; public wrappedobservablecollection(observablecollection<telement> baselist) { contract.requires(baselist != null); this.baselist = baselist; ((inotifypropertychanged)this.baselist).propertychanged += (sender, e) => propertychanged?.invoke(this, e); } #region wrapping of baselist public event propertychangedeventhandler propertychanged; #endregion }
Comments
Post a Comment