Component Association
Associate with parent and child component
Parent Component
@inherits BlazorComponentBase
<CascadingValue Value="this">
<ul @attributes="AdditionalAttributes">@ChildContent</ul>
</CascadingValue>[ParentComponent]
public class List : BlazorComponentBase
{
}Child Component
@inherits BlazorComponentBase
@attribute [ChildComponent(typeof(List))]
<!--For .NET 7 can use generic attribute-->
@attribute [ChildComponent<List>]
<li @attributes="@AdditionalAttributes">
@ChildContent
</li>
@code{
[CascadingParameter]public List CascadedList { get; set; }
protected override void BuildCssClass(ICssClassBuilder builder)
{
if(CascadedList.Active)
{
//..
}
}
}Optional
Last updated