BehaviorCollectionTemplate.cs 780 B

123456789101112131415161718192021222324
  1. using Avalonia.Markup.Xaml.Templates;
  2. using Avalonia.Metadata;
  3. using Avalonia.Styling;
  4. namespace Avalonia.Xaml.Interactivity;
  5. /// <summary>
  6. /// A template for creating a collection of <see cref="IBehavior"/> objects.
  7. /// </summary>
  8. public class BehaviorCollectionTemplate : ITemplate
  9. {
  10. /// <summary>
  11. /// Gets or sets the content of the template.
  12. /// </summary>
  13. [Content]
  14. [TemplateContent(TemplateResultType = typeof(BehaviorCollection))]
  15. public object? Content { get; set; }
  16. /// <summary>
  17. /// Builds the collection of behaviors from the template.
  18. /// </summary>
  19. /// <returns>The collection of behaviors created from the template.</returns>
  20. object? ITemplate.Build() => TemplateContent.Load<BehaviorCollection>(Content)?.Result;
  21. }