Closed tommyka closed 2 years ago
Can you give me a code sample to show the issue?
I forked the projeckt and created a testcase to reproduce it.
https://github.com/tommyka/BlazorTemplater/commit/91fd90deef6f415618298ff9983708d18b5bc012
But for the testing i did it do not same to be possible, because it fails in web components part.
This doesn't work because CascadingParameters
exist in the child component, not the parent. You've got a cascading parameter in CascadeChild.razor
, that's fine.
The CascadingParameter
in CascadeParentBase.cs
isn't correct. It should be a normal [Parameter]
. If you look in my original example, CascadeParent.razor
:
<p><CascadingValue Value="Info"><CascadeChild /></CascadingValue></p>
@code
{
[Parameter] public CascadeInfo Info { get; set; }
}
You can see the value comes from a regular parameter. Change your base to use [Parameter]
it will work correctly and you can set Info
.
Cascading properties use a provider-consumer model: the parent provides using a <CascadingValue>
component wrapped around the child components, and the child components use [CascadingParameter]
to consume the value.
Hope that clears it up.
If a component have a baseClass that it inherits from with the @inherits from a .cs file with a cascadeParameter, then its not possible to set that parameter.
It seams that when the parameters are fetched in GetParameterName that it gets the CascadingParameterAttribute instead of ParameterAttribute.