BlazorEventCallbackwithMultipleParams-howtorespondtoeventinparenthostcontrol

I have a blazor component with an EventCallBack parameter that utilized the new struct format allowing multiple arguments

[Parameter] public EventCallback<(EmployeeShiftDay, DateTime, DateTime)> NewDayScrolledIntoView { get; set; }

eventcallback is invoked in child normally as such

await NewDayScrolledIntoView.InvokeAsync(p1, p2, p3);

In my host page I have the corresponding method to handle the invoke

private void NewDayInView(EmployeeShiftDay dayInView, DateTime weekStart, DateTime weekEnd)
{
   ...
}

How do I add the markup for this EventCallBack in the host component - I need of course 3 params not just one

<ShiftCardScroller NewDayScrolledIntoView="@((args) => NewDayInView(args))" ></ShiftCardScroller>

回答

您正在调用它解构:

await NewDayScrolledIntoView.InvokeAsync((p1, p2, p3));

当接收到事件时,解构它然后:

<ShiftCardScroller NewDayScrolledIntoView="@((args)=> NewDayInView(args.Item1,args.Item2,args.Item3))" />


以上是BlazorEventCallbackwithMultipleParams-howtorespondtoeventinparenthostcontrol的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>