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?
E.g.
DialogService.OnClose += Close
Open Page as Dialog
Handle Close event
Thats it.
Must/Can i "disconnect" my Close Method from the DialogService?
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
break;
case Dialog2 :
// Do stuff for Dialog2
break;
default:
break;
}
await InvokeAsync(() => { StateHasChanged(); });
}