最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

blazor - How to raise an event back to the mainlayout page - Stack Overflow

programmeradmin6浏览0评论

I've tried a number of ways, but none seem to work for me.

We are using Blazor Server Side with .Net 8.

part of my mainlayout.razor page looks like this:

<RadzenSidebar @bind-Expanded="@sidebarExpanded" role="navigation" aria-labelledby="sidebarmenu">
    <RadzenPanelMenu id="sidebarmenu">
        <RadzenPanelMenuItem Text="Home" Icon="home" Path="/" />
    </RadzenPanelMenu>
</RadzenSidebar>
<RadzenBody>
    <div class="rz-p-4">
       <ErrorBoundary @ref="errorBoundary">
             <ChildContent>
                <CascadingValue Value="StartSave">
                    @Body
                </CascadingValue>
            </ChildContent>
            <ErrorContent>
                <Error ErrorDetail="@context"></Error>
            </ErrorContent>
        </ErrorBoundary>
    </div>
</RadzenBody>

The Casscading Value I have declared as:

[Parameter]
public EventCallback StartSave { 
    get; 
    set; 
}

In my home component, I want to use this callback. The idea is that I will have a general overlay for saving across pages, so I just want to send a signla back to the main page so that it knows to start the overlay. I'll then want to send a second signal to close the overlay.

Home component has:

 [CascadingParameter]
 public EventCallback StartSave { get; set; }

and I call it with:

await StartSave.InvokeAsync("start");

When I hit the await the code does not go back to the parent event. What Have I done wrong?

发布评论

评论列表(0)

  1. 暂无评论