private void SetValue(DependencyProperty dependencyProperty, DependencyPropertyKey dependencyPropertyKey, object value, bool setCurrentValue = false, BaseValueSource source = BaseValueSource.Unknown) { VerifyReadOnlyProperty(dependencyProperty, dependencyPropertyKey); IExpressionProvider newExpressionProvider = value as IExpressionProvider; if (newExpressionProvider == null && !dependencyProperty.IsValidValue(value)) { return; // invalid value } IDependencyPropertyValueEntry entry = GetInitializedValueEntry(dependencyProperty); IExpression oldExpression = setCurrentValue ? entry.GetBaseValue(false) as IExpression : // current value may be set in the top priority expression entry.GetBaseValue((int)source, false) as IExpression; if (newExpressionProvider != null) { value = newExpressionProvider.CreateExpression(this, dependencyProperty); } else if (oldExpression != null && oldExpression.SetValue(value)) { return; // value (current or not) was set in the existing expression, nothing else to do } if (setCurrentValue) { entry.SetCurrentValue(value); return; // base value isn't changed } if (oldExpression is IDisposable) // expression is being replaced { ((IDisposable)oldExpression).Dispose(); } entry.SetBaseValue((int)source, value); entry.ClearCurrentValue(); }
public void ClearCurrentValue() { source.ClearCurrentValue(); }