@inherits DComponentBase @implements IDisposable @* One item of a DAccordion: a DCollapse (so collapse + neo-raised, keyboard and aria-expanded come from there) whose open state is the accordion's Active index. Opening it closes the others; clicking it while open closes it. *@ @ChildContent @code { [CascadingParameter] DAccordion Parent { get; set; } [Parameter] public RenderFragment Header { get; set; } [Parameter] public RenderFragment ChildContent { get; set; } [Parameter] public bool Disabled { get; set; } [Parameter] public string HeaderClass { get; set; } [Parameter] public string ContentClass { get; set; } bool IsOpen => Parent.Active >= 0 && Parent.Active == Parent.IndexOf(this); protected override void OnInitialized() { if (Parent is null) throw new InvalidOperationException($"{nameof(DAccordionItem)} must be inside a {nameof(DAccordion)}."); Parent.Add(this); } Task OnIsOpenChanged(bool isOpen) => Parent.Select(isOpen ? Parent.IndexOf(this) : -1); public void Dispose() => Parent?.Remove(this); }