Beispiel #1
0
        /// <summary>
        /// Sets the inherited value of a dependency property on a DependencyObject. Do not use this method.
        /// </summary>
        /// <param name="dependencyProperty">The identifier of the dependency property to set.</param>
        /// <param name="value">The new local value.</param>
        /// <param name="recursively">Specifies if the inherited value must be applied to the children of this DependencyObject.</param>
        public void SetInheritedValue(DependencyProperty dependencyProperty, object value, bool recursively)
        {
            //-----------------------
            // CALL "SET INHERITED VALUE" ON THE STORAGE:
            //-----------------------
            var storage = INTERNAL_PropertyStore.GetInheritedPropertyStorage(this, dependencyProperty, createAndSaveNewStorageIfNotExists: true);

            INTERNAL_PropertyStore.SetInheritedValue(storage, value, recursively);
        }
Beispiel #2
0
        /// <summary>
        /// Sets the inherited value of a dependency property on a DependencyObject. Do not use this method.
        /// </summary>
        /// <param name="dependencyProperty">The identifier of the dependency property to set.</param>
        /// <param name="value">The new local value.</param>
        /// <param name="recursively">Specifies if the inherited value must be applied to the children of this DependencyObject.</param>
        public void SetInheritedValue(DependencyProperty dependencyProperty, object value, bool recursively)
        {
            //-----------------------
            // CALL "SET INHERITED VALUE" ON THE STORAGE:
            //-----------------------
            var storage = INTERNAL_PropertyStore.GetInheritedPropertyStorageOrCreateNewIfNotFound(this, dependencyProperty);

            INTERNAL_PropertyStore.SetInheritedValue(storage, value, recursively);
        }
Beispiel #3
0
        /// <summary>
        /// Sets the inherited value of a dependency property on a DependencyObject. Do not use this method.
        /// </summary>
        /// <param name="dp">The identifier of the dependency property to set.</param>
        /// <param name="value">The new local value.</param>
        /// <param name="recursively">Specifies if the inherited value must be applied to the children of this DependencyObject.</param>
        internal void SetInheritedValue(DependencyProperty dp, object value, bool recursively)
        {
            //-----------------------
            // CALL "SET INHERITED VALUE" ON THE STORAGE:
            //-----------------------
            INTERNAL_PropertyStorage storage;

            INTERNAL_PropertyStore.TryGetInheritedPropertyStorage(this, dp, true /*create*/, out storage);
            INTERNAL_PropertyStore.SetInheritedValue(storage, value, recursively);
        }
Beispiel #4
0
 internal void ResetInheritedProperties()
 {
     // Copy of the keys to allow removing items from the Dictionary furing the foreach.
     INTERNAL_PropertyStorage[] storages = this.INTERNAL_AllInheritedProperties.Values.ToArray();
     foreach (INTERNAL_PropertyStorage storage in storages)
     {
         INTERNAL_PropertyStore.SetInheritedValue(storage,
                                                  DependencyProperty.UnsetValue,
                                                  false); // recursively
         if (storage.BaseValueSourceInternal == BaseValueSourceInternal.Default)
         {
             // Remove storage if the effective value is the default value.
             this.INTERNAL_AllInheritedProperties.Remove(storage.Property);
             this.INTERNAL_PropertyStorageDictionary.Remove(storage.Property);
         }
     }
 }
Beispiel #5
0
 internal void ResetInheritedProperties()
 {
     // Copy of the keys to allow removing items from the Dictionary furing the foreach.
     INTERNAL_PropertyStorage[] storages = this.INTERNAL_AllInheritedProperties.Values.ToArray();
     foreach (INTERNAL_PropertyStorage storage in storages)
     {
         INTERNAL_PropertyStore.SetInheritedValue(storage,
                                                  DependencyProperty.UnsetValue,
                                                  false);                                 // recursively
         if (storage.BaseValueSourceInternal == BaseValueSourceInternal.Default &&
             (storage.PropertyListeners == null || storage.PropertyListeners.Count == 0)) //this second test is to make sure we keep any listener working (for example Bindings would stop working if we remove an element from the Visual tree then add it back))
         {
             // Remove storage if the effective value is the default value.
             this.INTERNAL_AllInheritedProperties.Remove(storage.Property);
             this.INTERNAL_PropertyStorageDictionary.Remove(storage.Property);
         }
     }
 }