I have a blazor application and I want to use EventCallback in my grandchild to call a function in my grandparent. The problem is, that the method in my grandparent never gets called.
I also use "normal" parameters to communicate from parent to child and in this case EventCallBack is working fine.
But doing it like this, it doesn't work:
This is the grandparent:
@page "/counter"@rendermode InteractiveServer<PageTitle>Counter</PageTitle><h1>Counter</h1><p role="status">Current count: @currentCount</p><CascadingValue Value="IncrementCount" Name="SetCount"><Child/></CascadingValue>@code { private int currentCount = 0; private void IncrementCount() { currentCount++; }}This is the child:
<h3>Child</h3><p>I'm only existing to demonstrate something...'</p><Grandchild/>@code {}And this the grandchild:
<h3>Grandchild</h3><button class="btn btn-primary" @onclick="HandleOnClick">Click me</button>@code { [CascadingParameter(Name = "SetCount")] public EventCallback SetCount { get; set; } private void HandleOnClick() { SetCount.InvokeAsync(); }}