/// <summary> /// Raises the <see cref="PropertyChanged"/> event. /// </summary> /// <param name="property">The property that has changed.</param> /// <param name="oldValue">The old property value.</param> /// <param name="newValue">The new property value.</param> /// <param name="priority">The priority of the binding that produced the value.</param> protected internal void RaisePropertyChanged <T>( AvaloniaProperty <T> property, Optional <T> oldValue, BindingValue <T> newValue, BindingPriority priority = BindingPriority.LocalValue) { property = property ?? throw new ArgumentNullException(nameof(property)); VerifyAccess(); property.Notifying?.Invoke(this, true); try { AvaloniaPropertyChangedEventArgs <T> e = null; var hasChanged = property.HasChangedSubscriptions; if (hasChanged || _propertyChanged != null) { e = new AvaloniaPropertyChangedEventArgs <T>( this, property, oldValue, newValue, priority); } OnPropertyChanged(property, oldValue, newValue, priority); if (hasChanged) { property.NotifyChanged(e); } _propertyChanged?.Invoke(this, e); if (_inpcChanged != null) { var inpce = new PropertyChangedEventArgs(property.Name); _inpcChanged(this, inpce); } if (property.Inherits && _inheritanceChildren != null) { foreach (var child in _inheritanceChildren) { child.InheritedPropertyChanged( property, oldValue, newValue.ToOptional()); } } } finally { property.Notifying?.Invoke(this, false); } }
private void UpdateValue(BindingValue <T> value) { if (value.HasValue && Property.ValidateValue?.Invoke(value.Value) == false) { value = Property.GetDefaultValue(_owner.GetType()); } if (value.Type == BindingValueType.DoNothing) { return; } var old = Value; if (value.Type != BindingValueType.DataValidationError) { Value = value.ToOptional(); } _sink.ValueChanged(Property, Priority, old, value); }