When creating a cascading value, specify the name attribute in the CascadingValue component. Then specify the name in the child component.
Parent component
@page "/cascading"
<CascadingValue Value="@Id" Name="EmpId">
<CascadingValue Value="@Name" Name="EmpName">
<CascadingChild></CascadingChild>
</CascadingValue>
</CascadingValue>
@code{
int Id = 1;
string Name = "Test";
}
Child component
<p>Employee Id:@EmployeeId </p>
<p>Employee Name:@EmployeeName </p>
@code{
[CascadingParameter(Name = "EmpId")]
private int EmployeeId { get; set; }
[CascadingParameter(Name = "EmpName")]
private string EmployeeName { get; set; }
}
Reference link
https://chrissainty.com/understanding-cascading-values-and-cascading-parameters/
Share with