diff --git a/src/Avalonia.Controls/Application.cs b/src/Avalonia.Controls/Application.cs index f0fe98a4b7..3bf72460df 100644 --- a/src/Avalonia.Controls/Application.cs +++ b/src/Avalonia.Controls/Application.cs @@ -260,7 +260,7 @@ namespace Avalonia try { _notifyingResourcesChanged = true; - ResourcesChanged?.Invoke(this, new ResourcesChangedEventArgs()); + ResourcesChanged?.Invoke(this, ResourcesChangedEventArgs.Empty); } finally { diff --git a/src/Avalonia.Styling/Controls/ResourceDictionary.cs b/src/Avalonia.Styling/Controls/ResourceDictionary.cs index cedd116e92..c56dd74143 100644 --- a/src/Avalonia.Styling/Controls/ResourceDictionary.cs +++ b/src/Avalonia.Styling/Controls/ResourceDictionary.cs @@ -146,7 +146,7 @@ namespace Avalonia.Controls if (hasResources) { - owner.NotifyHostedResourcesChanged(new ResourcesChangedEventArgs()); + owner.NotifyHostedResourcesChanged(ResourcesChangedEventArgs.Empty); } } @@ -171,14 +171,14 @@ namespace Avalonia.Controls if (hasResources) { - owner.NotifyHostedResourcesChanged(new ResourcesChangedEventArgs()); + owner.NotifyHostedResourcesChanged(ResourcesChangedEventArgs.Empty); } } } private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { - Owner?.NotifyHostedResourcesChanged(new ResourcesChangedEventArgs()); + Owner?.NotifyHostedResourcesChanged(ResourcesChangedEventArgs.Empty); } } } diff --git a/src/Avalonia.Styling/Controls/ResourcesChangedEventArgs.cs b/src/Avalonia.Styling/Controls/ResourcesChangedEventArgs.cs index 8e3acc0e88..ee2ece8a26 100644 --- a/src/Avalonia.Styling/Controls/ResourcesChangedEventArgs.cs +++ b/src/Avalonia.Styling/Controls/ResourcesChangedEventArgs.cs @@ -4,5 +4,6 @@ namespace Avalonia.Controls { public class ResourcesChangedEventArgs : EventArgs { + public static new readonly ResourcesChangedEventArgs Empty = new ResourcesChangedEventArgs(); } } diff --git a/src/Avalonia.Styling/StyledElement.cs b/src/Avalonia.Styling/StyledElement.cs index 09991f2ece..bdd01924f1 100644 --- a/src/Avalonia.Styling/StyledElement.cs +++ b/src/Avalonia.Styling/StyledElement.cs @@ -509,7 +509,7 @@ namespace Avalonia if (count > 0) { - e ??= new ResourcesChangedEventArgs(); + e ??= ResourcesChangedEventArgs.Empty; for (var i = 0; i < count; ++i) { @@ -803,13 +803,13 @@ namespace Avalonia { if (ResourcesChanged is object) { - e ??= new ResourcesChangedEventArgs(); + e ??= ResourcesChangedEventArgs.Empty; ResourcesChanged(this, e); } if (propagate) { - e ??= new ResourcesChangedEventArgs(); + e ??= ResourcesChangedEventArgs.Empty; NotifyChildResourcesChanged(e); } } diff --git a/src/Avalonia.Styling/Styling/Style.cs b/src/Avalonia.Styling/Styling/Style.cs index ae866ebf46..00819ef7be 100644 --- a/src/Avalonia.Styling/Styling/Style.cs +++ b/src/Avalonia.Styling/Styling/Style.cs @@ -67,7 +67,7 @@ namespace Avalonia.Styling if (hadResources || _resources.HasResources) { - Owner.NotifyHostedResourcesChanged(new ResourcesChangedEventArgs()); + Owner.NotifyHostedResourcesChanged(ResourcesChangedEventArgs.Empty); } } }