blazor-devexpress-dot-blazor-dot-itoastnotificationservice-dot-showtoast-1-x28-devexpress-dot-blazor-dot-toastoptions-x29.md
Creates and shows a toast notification with the specified options and a template.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
void ShowToast<T>(
ToastOptions toastOptions
)
where T : IComponent
| Name | Type | Description |
|---|---|---|
| toastOptions | ToastOptions |
An object that contains toast options.
|
| Name | Description |
|---|---|
| T |
The type of a toast template.
|
Call the ShowToast method to create and show a toast in code. Use the method parameters to set up the toast settings and add a template to the toast.
<DxButton Text="Show a toast" Click="AddToast" />
<DxButton Text="Hide a toast" Click="HideToast" />
<DxToastProvider DisplayTime="@TimeSpan.Zero" ThemeMode = "ToastThemeMode.Pastel" />
@code {
[Inject] IToastNotificationService ToastService { get; set; }
public class ToastButton : DxButton {
protected override Task OnParametersSetAsync() {
Text = "button1";
RenderStyleMode=ButtonRenderStyleMode.Outline;
return base.OnParametersSetAsync();
}
}
private void AddToast() {
ToastService.ShowToast<ToastButton>(new ToastOptions {
Id = "TaskNotification",
Title = "Toast with a button",
});
}
private void HideToast() {
ToastService.CloseToast("TaskNotification");
}
}
See Also
IToastNotificationService Interface