csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.2 KiB
43 lines
1.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using Avalonia.Collections;
|
|
|
|
namespace Avalonia.Controls
|
|
{
|
|
/// <summary>
|
|
/// A collection of <see cref="Control"/>s.
|
|
/// </summary>
|
|
public class Controls : AvaloniaList<Control>
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="Controls"/> class.
|
|
/// </summary>
|
|
public Controls()
|
|
{
|
|
Configure();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="Controls"/> class.
|
|
/// </summary>
|
|
/// <param name="items">The initial items in the collection.</param>
|
|
public Controls(IEnumerable<Control> 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.");
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|