DialogService - EventCallback parameter

Hello there,

I have a component that I would like to display as a dialog, it has a EventCallback parameter but I cannot pass in the method group as a parameter into the Open method:

As an aside I also noticed that you use dynamic type with the DialogService and I wondered if you considered refactoring to use generic T?
Ideally in setting the parameters we could use Action builder:

DialogService.Open<PresentationActionPanel>(action.Name, x =>
  x.SlideIndexChanged = SlideIndexChanged
}, options);

You can try creating a lambda from your SlideIndexChanged method and pass it instead. I don't think methods can be added to a dictionary.

Thanks - I worked arround it by adding the whole object as the parameter.

1 Like

I was having the same issue and I decided to try and manually create an EventCallback object with the delegate I wanted. Here is a snippet.

        public async Task AddUserClick(MouseEventArgs args)
        var result = await DialogService.OpenAsync<SearchAdUser>("Search User", new Dictionary<string, object>()
            { nameof(SearchAdUser.OnUserAdded), ReloadEventWrapper}
    private EventCallback ReloadEventWrapper => new(null, (Action)(async () =>
        await grid0.Reload();
        await InvokeAsync(StateHasChanged);
1 Like

And how does the Parameter looks like in SearchAddUser component? Can you provide it to me? Thank you in advance.