Skip to content

Commit

Permalink
feat: add another overload of property setter. (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbitism authored Apr 14, 2024
1 parent a64e348 commit 9c75f57
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ public static void SetValue<T>(this AvaloniaProperty<T> property, T value, param
obj?.SetValue(property, value);
}
}

public static void SetValue<TValue, TItem>(this AvaloniaProperty<TValue> property, TValue value, params TItem?[] objects) where TItem: AvaloniaObject
{
foreach (var obj in objects)
{
obj?.SetValue(property, value);
}
}

public static void AffectsPseudoClass<TControl>(this AvaloniaProperty<bool> property, string pseudoClass, RoutedEvent<RoutedEventArgs>? routedEvent = null)
where TControl: Control
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 9c75f57

Please sign in to comment.