Closed
Description
Describe the bug
My event is not called in the parent component when using EventCallBack in a child component.
I've already been through #12116 and #8385 but It still not working
To Reproduce
My code:
Tree.razor (child)
@typeparam TNode
<HTML WITH DOUBLECLICK EVENT>
@code{
[Parameter] public EventCallback<DoubleClickVariableEventArgs> OnDoubleClickOnVariable { get; set; }
private void OnDoubleClickTree(object sender, MouseEventArgs e)
{
Console.WriteLine("TEST");
OnDoubleClickOnVariable.InvokeAsync(new DoubleClickVariableEventArgs(selectedNode.Path, selectedNode.IsReadOnly));}
}
"TEST" is correctly displayed in the console. so the problem is from InvokeAsync.
My eventargs:
public class DoubleClickVariableEventArgs : EventArgs
{
public DoubleClickVariableEventArgs(string path ,bool isReadOnly)
{
Path = path;
IsReadOnly = isReadOnly;
}
public string Path { get; private set; }
public bool IsReadOnly { get; private set; }
}
MAIN.razor (parent)
<Tree TNode="TreeItem" Nodes="Items" ChildSelector="@(item => item.Childs)" @bind-SelectedNode="selectedNode" @bind-ExpandedNodes="ExpandedNodes" HasChildNodes="@(item => item.Childs?.Any() == true)" OnDoubleClickOnVariable="OnVariableDoubleClick">
<TitleTemplate>@context.Text</TitleTemplate>
</Tree>
@code{
private async Task OnVariableDoubleClick(DoubleClickVariableEventArgs e)
{
Console.WriteLine("TEST2");
}
}
I tried some of the solutions like writing the type : TNode = "TreeItem"
or writing OnDoubleClickOnVariable="(DoubleClickVariableEventArgs x) => OnVariableDoubleClick(x)"
Without success...
I want to say that I used the exact same structure in another non-generic component and it's working perfectly.
Further technical details
Lastest Blazor, VS Preview versions
P.S. On of my first post on github sorry if it's unreadable