Browse Source
Merge pull request #10373 from AvaloniaUI/fixes/directproperty-change-api-tweaks
Tweak API for raising direct property changes.
pull/10380/head
Max Katz
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
8 additions and
22 deletions
-
src/Avalonia.Base/AvaloniaObject.cs
-
src/Avalonia.Base/StyledElement.cs
-
src/Avalonia.Base/Visual.cs
-
src/Avalonia.Controls/Primitives/SelectingItemsControl.cs
|
|
|
@ -664,14 +664,12 @@ namespace Avalonia |
|
|
|
/// <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<T>( |
|
|
|
DirectPropertyBase<T> property, |
|
|
|
Optional<T> oldValue, |
|
|
|
BindingValue<T> newValue, |
|
|
|
BindingPriority priority = BindingPriority.LocalValue) |
|
|
|
T oldValue, |
|
|
|
T newValue) |
|
|
|
{ |
|
|
|
RaisePropertyChanged(property, oldValue, newValue, priority, true); |
|
|
|
RaisePropertyChanged(property, oldValue, newValue, BindingPriority.LocalValue, true); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -720,7 +718,7 @@ namespace Avalonia |
|
|
|
/// <returns>
|
|
|
|
/// True if the value changed, otherwise false.
|
|
|
|
/// </returns>
|
|
|
|
protected bool SetAndRaise<T>(AvaloniaProperty<T> property, ref T field, T value) |
|
|
|
protected bool SetAndRaise<T>(DirectPropertyBase<T> property, ref T field, T value) |
|
|
|
{ |
|
|
|
VerifyAccess(); |
|
|
|
|
|
|
|
|
|
|
|
@ -524,13 +524,7 @@ namespace Avalonia |
|
|
|
NotifyResourcesChanged(); |
|
|
|
} |
|
|
|
|
|
|
|
#nullable disable |
|
|
|
RaisePropertyChanged( |
|
|
|
ParentProperty, |
|
|
|
new Optional<StyledElement>(old), |
|
|
|
new BindingValue<StyledElement>(Parent), |
|
|
|
BindingPriority.LocalValue); |
|
|
|
#nullable enable |
|
|
|
RaisePropertyChanged(ParentProperty, old, Parent); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -573,7 +573,7 @@ namespace Avalonia |
|
|
|
/// <param name="newParent">The new visual parent.</param>
|
|
|
|
protected virtual void OnVisualParentChanged(Visual? oldParent, Visual? newParent) |
|
|
|
{ |
|
|
|
RaisePropertyChanged(VisualParentProperty, oldParent, newParent, BindingPriority.LocalValue); |
|
|
|
RaisePropertyChanged(VisualParentProperty, oldParent, newParent); |
|
|
|
} |
|
|
|
|
|
|
|
internal override ParametrizedLogger? GetBindingWarningLogger( |
|
|
|
|
|
|
|
@ -345,10 +345,7 @@ namespace Avalonia.Controls.Primitives |
|
|
|
|
|
|
|
if (_oldSelectedItems != SelectedItems) |
|
|
|
{ |
|
|
|
RaisePropertyChanged( |
|
|
|
SelectedItemsProperty, |
|
|
|
new Optional<IList?>(_oldSelectedItems), |
|
|
|
new BindingValue<IList?>(SelectedItems)); |
|
|
|
RaisePropertyChanged(SelectedItemsProperty, _oldSelectedItems, SelectedItems); |
|
|
|
_oldSelectedItems = SelectedItems; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -909,10 +906,7 @@ namespace Avalonia.Controls.Primitives |
|
|
|
else if (e.PropertyName == nameof(InternalSelectionModel.WritableSelectedItems) && |
|
|
|
_oldSelectedItems != (Selection as InternalSelectionModel)?.SelectedItems) |
|
|
|
{ |
|
|
|
RaisePropertyChanged( |
|
|
|
SelectedItemsProperty, |
|
|
|
new Optional<IList?>(_oldSelectedItems), |
|
|
|
new BindingValue<IList?>(SelectedItems)); |
|
|
|
RaisePropertyChanged(SelectedItemsProperty, _oldSelectedItems, SelectedItems); |
|
|
|
_oldSelectedItems = SelectedItems; |
|
|
|
} |
|
|
|
else if (e.PropertyName == nameof(ISelectionModel.Source)) |
|
|
|
|