Пример #1
0
        [FriendAccessAllowed] // Built into Base, also used by Core & Framework.
        internal bool ProvideSelfAsInheritanceContext( DependencyObject doValue, DependencyProperty dp ) 
        {
            // We have to call Freezable.AddInheritanceContext even if the request
            // for a new InheritanceContext is not allowed, because Freezable depends
            // on side-effects from setting the "Freezable context".  Freezable's 
            // implementation does its own checks of the conditions omitted here.
            // 
 

            if (doValue != null && 
                this.ShouldProvideInheritanceContext(doValue, dp) &&
                (doValue is Freezable ||
                    (this.CanBeInheritanceContext &&
                     !doValue.IsInheritanceContextSealed) 
                ))
            { 
                DependencyObject oldInheritanceContext = doValue.InheritanceContext; 
                doValue.AddInheritanceContext(this, dp);
 
                // return true if the inheritance context actually changed to the new value
                return (this == doValue.InheritanceContext && this != oldInheritanceContext);
            }
            else 
            {
                return false; 
            } 
        }