Esempio n. 1
0
        internal override void OnDetached(DependencyObject element)
        {
            if (IsAttached)
            {
                base.OnDetached(element);
                if (PropertyListener != null)
                {
                    PropertyListener.Detach();
                    PropertyListener = null;
                }

                PropertyPathWalker.Update(null);

                Target = null;
            }
        }
        internal void OnDetached(DependencyObject element)
        {
            if (IsAttached)
            {
                this.IsAttached = false;
                this.OnDataContextChanged(null);

                if (PropertyListener != null)
                {
                    PropertyListener.Detach();
                    PropertyListener = null;
                }

                PropertyPathWalker.Update(null);

                Target = null;
            }
        }
Esempio n. 3
0
        internal void OnDetached(DependencyObject element)
        {
            if (IsAttached)
            {
                this.IsAttached = false;

                if (_propertyListener != null)
                {
                    _propertyListener.Detach();
                    _propertyListener = null;
                }

                propertyPathWalker.Update(null);

                Target.InheritedContextChanged -= new EventHandler(this.OnTargetInheritedContextChanged);
                Target = null;
            }
        }
Esempio n. 4
0
        internal override void OnSourceChanged(object oldvalue, object newValue)
        {
            IPropertyChangedListener listener = _dpListener;

            if (listener != null)
            {
                _dpListener = null;
                listener.Detach();
            }

            DependencyObject sourceDO = SourceDO;

            if (sourceDO != null)
            {
                _dpListener = INTERNAL_PropertyStore.ListenToChanged(
                    sourceDO, _dp, OnPropertyChanged
                    );
            }
        }
Esempio n. 5
0
        internal override void OnDetach(DependencyObject d, DependencyProperty dp)
        {
            if (!IsAttached)
            {
                return;
            }

            this.IsAttached = false;

            if (_propertyListener != null)
            {
                _propertyListener.Detach();
                _propertyListener = null;
            }

            propertyPathWalker.Update(null);

            Target.InheritedContextChanged -= new EventHandler(this.OnTargetInheritedContextChanged);
            Target = null;
        }
        internal override void OnSourceChanged(object oldValue, object newValue)
        {
            if (oldValue is INotifyPropertyChanged inpc)
            {
                inpc.PropertyChanged -= new PropertyChangedEventHandler(OnSourcePropertyChanged);
            }

            IPropertyChangedListener listener = _dpListener;

            if (listener != null)
            {
                _dpListener = null;
                listener.Detach();
            }

            _dp    = null;
            _prop  = null;
            _field = null;

            if (Source == null)
            {
                return;
            }

            if (_bindsDirectlyToSource)
            {
                return;
            }

            inpc = newValue as INotifyPropertyChanged;
            if (inpc != null)
            {
                inpc.PropertyChanged += new PropertyChangedEventHandler(OnSourcePropertyChanged);
            }

            if (newValue is DependencyObject sourceDO)
            {
                Type type = _resolvedType ?? Source.GetType();

                DependencyProperty dependencyProperty = INTERNAL_TypeToStringsToDependencyProperties.GetPropertyInTypeOrItsBaseTypes(type, _propertyName);

                if (dependencyProperty != null)
                {
                    _dp         = dependencyProperty;
                    _dpListener = listener = INTERNAL_PropertyStore.ListenToChanged(sourceDO, dependencyProperty, OnPropertyChanged);
                }
            }

            if (_dp == null)
            {
                Type sourceType = Source.GetType();
                for (Type t = sourceType; t != null; t = t.BaseType)
                {
                    _prop = t.GetProperty(
                        _propertyName,
                        BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly
                        );

                    if (_prop != null)
                    {
                        break;
                    }
                }

                if (_prop == null)
                {
                    // Try in case it is a simple field instead of a property:
                    _field = sourceType.GetField(_propertyName);
                }
            }
        }