DialogService use it in a C# file

Hello all,

I am trying to use dialog service in class file. I have a wrapper service result model and I want to show a dialog if any error occurs but I cant use it. I dont know the way to use the dialog sevice in another or use it as static

thanks in Advance

You might need to check what code generates Radzen Blazor Studio from CRUD pages templates:

I thank you for your anwser but I think that I wasnt cleared. I want to use the Dialog service in a another service, lets say inside a wrapper. example

MyService{
ShowAlert(){
DialogService.Alert(error, title)
}
}

You can use it in whatever place, however you need to inject it as shown in my previous reply. You can read also about Blazor Dependency Injection here:

I tried with the previous example but the DialogService is null. I will try after reading your link and I dont manage it I maybe contact you again.

Thanks a lot have a nice day

Something like this?

public class UIHelpers : IUIHelpers
    {
        private readonly NotificationService _notificationService;
        private readonly DialogService _dialogService;
        public UIHelpers(NotificationService notificationService, DialogService dialogService)
        {
            _notificationService = notificationService;
            _dialogService = dialogService;
        }

        public void ShowNotification(string text)
        {
            var message = new NotificationMessage { Severity = NotificationSeverity.Info, Summary = "", Detail = text, Duration = 4000, CloseOnClick = true, Payload = DateTime.Now };
            _notificationService.Notify(message);
        }

        public void OpenDialog<T>(string title, int id) where T: ComponentBase
        {
            _dialogService.Open<T>($"<b>{title}</b>",
              new Dictionary<string, object>() { { "Id", id } },
              new DialogOptions() { Width = "1200px" });
        }

        public event Action<dynamic> OnDialogClose
        {
            add { _dialogService.OnClose += value; }
            remove { _dialogService.OnClose -= value; }
        }
    }

yeah but it doesnt work. I am trying to use it here


and I declared it here :
image

May be something along these things?