I have a custom component which takes RenderFragment and displays it as ChildContent. I'm passing TelerikForm for ChildContent and getting such error: Unhandled exception rendering component: Specified cast is not valid.
Here's the custom component:
<div class="gg_wizard_step @(IndexInParent != ParentSection.CurrentStep ? "hidden" : "")">
<CascadingValue Value="this">
@ChildContent
</CascadingValue>
</div>
@code {
[Parameter]
public RenderFragment ChildContent { get; set; }
[CascadingParameter]
public NLWizardSection ParentSection { get; set; }
[Parameter]
public int IndexInParent { get; set; }
protected override void OnInitialized()
{
base.OnInitialized();
ParentSection.AddChild(this);
}
}
Here's the form added to custom component:
<NLWizardStep>
<h3>@L["What is the name of your resource?"]</h3>
<TelerikForm Model="@((NameForm)_currentForm)"
@ref="NameFormRef"
ValidationMessageType="FormValidationMessageType.Inline">
<FormValidation>
<DataAnnotationsValidator></DataAnnotationsValidator>
<CustomValidation></CustomValidation>
</FormValidation>
<FormItems>
<FormItem Field="@nameof(NameForm.Name)"></FormItem>
</FormItems>
<FormButtons></FormButtons>
</TelerikForm>
</NLWizardStep>