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, Nullable<MBNotifierCloseMethod>, String, String, IMBIconFoundry, Nullable<Boolean>, Nullable<UInt32>, Boolean) 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
});
Namespace: Material.Blazor
Assembly: Material.Blazor.dll
Syntax
public interface IMBToastService
Properties
| Improve this Doc View SourceConfiguration
Toast service configuration
Declaration
MBToastServiceConfiguration Configuration { get; set; }
Property Value
Type | Description |
---|---|
MBToastServiceConfiguration |
Methods
| Improve this Doc View SourceShowToast(MBToastLevel, String, String, Nullable<MBNotifierCloseMethod>, String, String, IMBIconFoundry, Nullable<Boolean>, Nullable<UInt32>, Boolean)
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.
Declaration
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
Type | Name | Description |
---|---|---|
MBToastLevel | level | Severity of the toast (info, error, etc) |
String | message | Body text in the toast |
String | heading | Text used in the heading of the toast |
Nullable<MBNotifierCloseMethod> | closeMethod | close method |
String | cssClass | additional css applied to toast |
String | iconName | Icon name |
IMBIconFoundry | iconFoundry | The icon's foundry |
Nullable<Boolean> | showIcon | Show or hide icon |
Nullable<UInt32> | timeout | Length of time before autodismiss |
Boolean | debug | If true only shows toasts when compiling in DEBUG mode |
Events
| Improve this Doc View SourceOnAdd
A event that will be invoked when showing a toast
Declaration
event Action<MBToastLevel, MBToastSettings> OnAdd
Event Type
Type | Description |
---|---|
Action<MBToastLevel, MBToastSettings> |
OnTriggerStateHasChanged
A event that will be invoked when toasts should call StateHasChanged. This will be when the configuration is updated.
Declaration
event Action OnTriggerStateHasChanged
Event Type
Type | Description |
---|---|
Action |