diff --git a/src/Irihi.Avalonia.Shared.Public/Helpers/AvaloniaPropertyExtension.cs b/src/Irihi.Avalonia.Shared.Public/Helpers/AvaloniaPropertyExtension.cs index ca0cf9f..7b02340 100644 --- a/src/Irihi.Avalonia.Shared.Public/Helpers/AvaloniaPropertyExtension.cs +++ b/src/Irihi.Avalonia.Shared.Public/Helpers/AvaloniaPropertyExtension.cs @@ -13,6 +13,14 @@ public static void SetValue(this AvaloniaProperty property, T value, param obj?.SetValue(property, value); } } + + public static void SetValue(this AvaloniaProperty property, TValue value, params TItem?[] objects) where TItem: AvaloniaObject + { + foreach (var obj in objects) + { + obj?.SetValue(property, value); + } + } public static void AffectsPseudoClass(this AvaloniaProperty property, string pseudoClass, RoutedEvent? routedEvent = null) where TControl: Control diff --git a/test/Irihi.Avalonia.Shared.UnitTest.Public/Helpers/AvaloniaPropertyExtensionTest.cs b/test/Irihi.Avalonia.Shared.UnitTest.Public/Helpers/AvaloniaPropertyExtensionTest.cs index 70d32c1..8e78b2e 100644 --- a/test/Irihi.Avalonia.Shared.UnitTest.Public/Helpers/AvaloniaPropertyExtensionTest.cs +++ b/test/Irihi.Avalonia.Shared.UnitTest.Public/Helpers/AvaloniaPropertyExtensionTest.cs @@ -33,4 +33,15 @@ public void Property_SetValue_Effective() Visual.IsVisibleProperty.SetValue(true, b); Assert.True(b.IsVisible); } + + [Fact] + public void Property_MultipleObject_InArray() + { + Button b1 = new Button(); + Button b2 = new Button(); + Button[] buttons = {b1, b2}; + Visual.IsVisibleProperty.SetValue(true, buttons); + Assert.True(b1.IsVisible); + Assert.True(b2.IsVisible); + } } \ No newline at end of file