public IDisposable TryObserve(object source, IEventListener listener) { if (_isDataContext) { return(WeakEventManager.AddBindingContextListener(BindingServiceProvider.ContextManager.GetBindingContext(source), listener, true)); } if (_memberEvent == null) { if (_isDynamic) { return(((IDynamicObject)source).TryObserve(_path, listener)); } return(_indexerAttachedBindingMember?.TryObserve(source, listener)); } return(_memberEvent.SetSingleValue(source, listener) as IDisposable); }
private void Update(object source) { if (_parentContext != null) { WeakEventManager.RemoveBindingContextListener(_parentContext, this); } if (source == null) { _parentContext = null; } else { _parentContext = GetParentBindingContext(source); if (_parentContext != null) { WeakEventManager.AddBindingContextListener(_parentContext, this, false); } } }