Table of Contents

Interface IMBToastService

Namespace
Material.Blazor
Assembly
Material.Blazor.dll

Interface for the Material.Blazor toast service, developed from the code base of Blazored Toast by Chris Sainty. Works in conjunction with a MBAnchor that must be placed in either App.razor or MainLayout.razor to avoid an exception being thrown when you first attempt to show a toast notification.

Throws a InvalidOperationException if ShowToast(MBToastLevel, string, string, MBNotifierCloseMethod?, string, string, IMBIconFoundry?, bool?, uint?, bool) is called without an MBAnchor component used in the app.

You can optionally add configuration when you add this to the service collection:

services.AddMBServices(toastServiceConfiguration: new MBToastServiceConfiguration()
                                                                                                     {
                                                                                                         Postion = MBToastPosition.TopRight,
                                                                                                         CloseMethod = MBToastCloseMethod.Timeout,
                                                                                                         ... etc
                                                                                                     });
public interface IMBToastService

Properties

Configuration

Toast service configuration

MBToastServiceConfiguration Configuration { get; set; }

Property Value

MBToastServiceConfiguration

Methods

ShowToast(MBToastLevel, string, string, MBNotifierCloseMethod?, string, string, IMBIconFoundry?, bool?, uint?, bool)

Shows a toast using the supplied settings. Only the level and message parameters are required, with the remainder haveing defaults specified by the MBToastServiceConfiguration that you can supply when registering services. Failing that Material.Blazor provides defaults.

void ShowToast(MBToastLevel level, string message, string heading = null, MBNotifierCloseMethod? closeMethod = null, string cssClass = null, string iconName = null, IMBIconFoundry? iconFoundry = null, bool? showIcon = null, uint? timeout = null, bool debug = false)

Parameters

level MBToastLevel

Severity of the toast (info, error, etc)

message string

Body text in the toast

heading string

Text used in the heading of the toast

closeMethod MBNotifierCloseMethod?

close method

cssClass string

additional css applied to toast

iconName string

Icon name

iconFoundry IMBIconFoundry

The icon's foundry

showIcon bool?

Show or hide icon

timeout uint?

Length of time before autodismiss

debug bool

If true only shows toasts when compiling in DEBUG mode

Events

OnAdd

A event that will be invoked when showing a toast

event Action<MBToastLevel, MBToastSettings> OnAdd

Event Type

Action<MBToastLevel, MBToastSettings>

OnTriggerStateHasChanged

A event that will be invoked when toasts should call StateHasChanged. This will be when the configuration is updated.

event Action OnTriggerStateHasChanged

Event Type

Action