/// <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); } }
/// <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 void RaisePropertyChanged( AvaloniaProperty property, object oldValue, object newValue, BindingPriority priority = BindingPriority.LocalValue) { Contract.Requires <ArgumentNullException>(property != null); VerifyAccess(); AvaloniaPropertyChangedEventArgs e = new AvaloniaPropertyChangedEventArgs( this, property, oldValue, newValue, priority); property.Notifying?.Invoke(this, true); try { OnPropertyChanged(e); property.NotifyChanged(e); _propertyChanged?.Invoke(this, e); if (_inpcChanged != null) { PropertyChangedEventArgs e2 = new PropertyChangedEventArgs(property.Name); _inpcChanged(this, e2); } if (property.Inherits) { _inheritablePropertyChanged?.Invoke(this, e); } } finally { property.Notifying?.Invoke(this, false); } }