예제 #1
0
        private void SetValueInternal(DependencyProperty dp, object oldValue, object newValue)
        {
            PropertyMetadata metadata = dp.GetMetadata(this);

            if (metadata.CoerceValueCallback != null)
            {
                newValue = metadata.CoerceValueCallback(this, newValue);
            }

            if (newValue != DependencyProperty.UnsetValue && dp.IsValidValue(newValue))
            {
                this.properties[dp] = newValue;
            }
            else
            {
                this.properties.Remove(dp);
                newValue = this.GetValue(dp);
            }

            if (!this.AreEqual(oldValue, newValue))
            {
                this.OnPropertyChanged(new DependencyPropertyChangedEventArgs(dp, oldValue, newValue));
            }
        }
예제 #2
0
        private void SetValueInternal(DependencyProperty dp, object oldValue, object newValue)
        {
            PropertyMetadata metadata = dp.GetMetadata(this);
            
            if (metadata.CoerceValueCallback != null)
            {
                newValue = metadata.CoerceValueCallback(this, newValue);
            }

            if (newValue != DependencyProperty.UnsetValue && dp.IsValidValue(newValue))
            {
                this.properties[dp] = newValue;
            }
            else
            {
                this.properties.Remove(dp);
                newValue = this.GetValue(dp);
            }

            if (!this.AreEqual(oldValue, newValue))
            {
                this.OnPropertyChanged(new DependencyPropertyChangedEventArgs(dp, oldValue, newValue));
            }
        }