Julien Lebosquain
4 years ago
No known key found for this signature in database
GPG Key ID: 1833CAD10ACC46FD
2 changed files with
24 additions and
2 deletions
-
src/Avalonia.Controls/Controls.cs
-
tests/Avalonia.Controls.UnitTests/PanelTests.cs
|
|
|
@ -1,3 +1,4 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using Avalonia.Collections; |
|
|
|
|
|
|
|
@ -13,7 +14,7 @@ namespace Avalonia.Controls |
|
|
|
/// </summary>
|
|
|
|
public Controls() |
|
|
|
{ |
|
|
|
ResetBehavior = ResetBehavior.Remove; |
|
|
|
Configure(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -21,9 +22,22 @@ namespace Avalonia.Controls |
|
|
|
/// </summary>
|
|
|
|
/// <param name="items">The initial items in the collection.</param>
|
|
|
|
public Controls(IEnumerable<Control> items) |
|
|
|
: base(items) |
|
|
|
{ |
|
|
|
Configure(); |
|
|
|
AddRange(items); // virtual member call in ctor, ok for our current implementation
|
|
|
|
} |
|
|
|
|
|
|
|
private void Configure() |
|
|
|
{ |
|
|
|
ResetBehavior = ResetBehavior.Remove; |
|
|
|
Validate = item => |
|
|
|
{ |
|
|
|
if (item is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(item), |
|
|
|
$"A null control cannot be added to a {nameof(Controls)} collection."); |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -1,3 +1,4 @@ |
|
|
|
using System; |
|
|
|
using System.Linq; |
|
|
|
using Avalonia.LogicalTree; |
|
|
|
using Avalonia.Media; |
|
|
|
@ -133,5 +134,12 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
|
|
|
|
renderer.Verify(x => x.AddDirty(target), Times.Once); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Adding_Null_Child_Should_Throw() |
|
|
|
{ |
|
|
|
var panel = new Panel(); |
|
|
|
Assert.Throws<ArgumentNullException>(() => panel.Children.Add(null!)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|