/// <summary> /// Clear this field from the given DependencyObject instance. /// </summary> /// <param name="instance"></param> public void ClearValue(DependencyObject instance) { if (instance != null) { EntryIndex entryIndex = instance.LookupEntry(_globalIndex); instance.UnsetEffectiveValue(entryIndex, null /* dp */, null /* metadata */); } else { throw new ArgumentNullException("instance"); } }
/// <summary> /// Write the given value onto a DependencyObject instance. /// </summary> /// <param name="instance">The DependencyObject on which to set the value.</param> /// <param name="value">The value to set.</param> public void SetValue(DependencyObject instance, T value) { if (instance != null) { EntryIndex entryIndex = instance.LookupEntry(_globalIndex); // Set the value if it's not the default, otherwise remove the value. if (!object.ReferenceEquals(value, _defaultValue)) { instance.SetEffectiveValue(entryIndex, null /* dp */, _globalIndex, null /* metadata */, value, BaseValueSourceInternal.Local); _hasBeenSet = true; } else { instance.UnsetEffectiveValue(entryIndex, null /* dp */, null /* metadata */); } } else { throw new ArgumentNullException("instance"); } }