Author : MD TAREQ HASSAN | Updated : 2020/08/12

What is Cascading parameter and value?

Basic Usage

Main.razor

<CascadingValue Value="@Name">
    <FooComponent></FooComponent>
    <BarComponent></BarComponent>
</CascadingValue>

@code {
    int Name = "hovermind";
}

FooComponent.razor

<h1>Foo Component</h1>

<p>Parent name: @ParentName</p>

@code {
    [CascadingParameter] string ParentName { get; set; }
}

BarComponent.razor

<h1>Bar Component</h1>

<p>Parent name: @ParentName</p>

@code {
    [CascadingParameter] string ParentName { get; set; }
}