Interface IMBToastService
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
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
MBToastLevelSeverity of the toast (info, error, etc)
message
stringBody text in the toast
heading
stringText used in the heading of the toast
closeMethod
MBNotifierCloseMethod?close method
cssClass
stringadditional css applied to toast
iconName
stringIcon name
iconFoundry
IMBIconFoundryThe icon's foundry
showIcon
bool?Show or hide icon
timeout
uint?Length of time before autodismiss
debug
boolIf 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
OnTriggerStateHasChanged
A event that will be invoked when toasts should call StateHasChanged. This will be when the configuration is updated.
event Action OnTriggerStateHasChanged