Skip to main content
You are viewing help content for pre-release software. This document and the features it describes are subject to change.
All docs
V24.1

IToastNotificationService Interface

Allows you to manage toast notifications in code.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

Declaration

public interface IToastNotificationService

Remarks

The toast notification service allows you to create, show, and close toast notifications in code. To use the service, inject it with the [Inject] attribute.

[Inject] IToastNotificationService ToastService { get; set; }

Use methods implemented by the interface to manage toast notifications in code.

  • The ShowToast method overloads allow you to create and show toast notifications at runtime or to show DxToast components declared in markup.

    <DxButton Text="Create a toast" Click="CreateToastAtRuntime" />
    <DxButton Text="Show a declared toast" Click="ShowDeclaredToast" />
    <DxToastProvider />
    
    <DxToast Id="toast1" Text="The toast specified in markup." />
    
    @code {
        [Inject] IToastNotificationService ToastService { get; set; }
    
        private void CreateToastAtRuntime() {
            ToastService.ShowToast(new ToastOptions {
                Id = "toast2",
                Title = "New toast",
                Text = "The new toast is created.",
            });
        }
        private void ShowDeclaredToast() {
            ToastService.ShowToast("toast1");
        }
    }
    
  • The CloseToast(String) method allows you to close toast notifications.

    ToastService.CloseToast("toast1");
    ToastService.CloseToast("toast2");
    
See Also