Live Chat Icon For mobile
Live Chat Icon

What are cascading values and parameters? How do you use them? How do you pass data from a fifth- or sixth-level child component to a root parent component in Blazor?

Platform: Blazor| Category: Components

Cascading values and parameters are used to pass a value from a component to all its descendants without having to use traditional component parameters. Blazor comes with a special component called CascadingValue. This component allows whatever value is passed to it to be cascaded down its component tree to all of its descendants. The descendant components can then choose to collect the value by declaring a property of the same type, decorated with the [CascadingParameter] attribute.

Parent component

@page "/cascading"
<CascadingValue Value="@Name">
@code {
	string Name = "Steve";

Child component

<p>Employee Name:@Name </p>
@code {
	private string Name { get; set; }

Reference link:

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.