Close Event

Hello Radzen Team,
i have some code to handle the Close event. Works great.
But... now every Close Event is running through this code. Is this normal?
Can i change this to only handle the Close event of one specific page?
DialogService.OnClose += Close
Open Page as Dialog
Handle Close event
Thats it.
Must/Can i "disconnect" my Close Method from the DialogService?


Please Help...

From what I've seen you can not. You have to differentiate the dialogs somehow. just make sure you open dialog with the const variable as a title and this should work.

    private const string Dialog1 = "Dialog1";
    private const string Dialog2 = "Dialog2";
    private string currentDialog = "";
    async void DialogOpen(string title, Type type, Dictionary<string, object> parameters, DialogOptions options)
         this.currentDialog = title;
         await InvokeAsync(() => { StateHasChanged(); });

    async void DialogClose(dynamic result)
        if (result == null) return;
        bool r = (bool)result;
        switch (this.currentDialog)
            case Dialog1 :
               // Do stuff for Dialog1
            case Dialog2 :
                // Do stuff for Dialog2
        await InvokeAsync(() => { StateHasChanged(); });

Another option is to just use the result returned from OpenDialog:

var result = await dialogService.OpenAsyc<DialogPage>();

Then you don't need to handle the OnClose event of the service at all.

1 Like

You should add this to the examples! That makes everything much easier.