Class ToastBeforeCloseArgs
Specifies the event arguments for the Toast before close event.
Inheritance
Namespace: Syncfusion.Blazor.Notifications
Assembly: Syncfusion.Blazor.dll
Syntax
public class ToastBeforeCloseArgs : Object
Remarks
This class provides data for the event that is raised before a Toast notification is closed. It allows you to cancel the closing of the Toast, identify which Toast is being closed, and understand how the close action was triggered.
Examples
<SfToast @ref="ToastRef">
<ToastEvents TValue="ToastModel" BeforeClose="@OnBeforeClose"></ToastEvents>
</SfToast>
private void OnBeforeClose(ToastBeforeCloseArgs args)
{
// Prevent closing if user interaction is required
if (args.RequestType == "User")
{
args.Cancel = true;
}
// Log which toast is closing
Console.WriteLine($"Toast with Key {args.Key} is closing");
}
Constructors
ToastBeforeCloseArgs()
Declaration
public ToastBeforeCloseArgs()
Properties
Cancel
Gets or sets a value indicating whether the Toast closing should be cancelled.
Declaration
public bool Cancel { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
Setting this property to true
prevents the Toast from being closed and removed from the display.
This is useful for implementing confirmation dialogs or preventing accidental closure of important notifications.
Key
Gets or sets the unique identifier of the Toast being closed.
Declaration
public int Key { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | An integer value representing the unique key of the Toast notification. Each Toast is assigned a unique key when created. |
Remarks
The Key property helps identify which specific Toast notification is being closed when multiple Toast messages are displayed. This is particularly useful in scenarios where you need to track or perform specific actions based on which Toast is closing.
Options
Gets or sets the current Toast model properties as options.
Declaration
public ToastModel Options { get; set; }
Property Value
Type | Description |
---|---|
ToastModel | An instance of ToastModel representing the configuration options for the Toast notification being closed. Can be |
Remarks
This property provides access to the complete configuration of the Toast that is being closed. You can use this information to log details about the Toast, perform cleanup operations, or make decisions about subsequent actions.
RequestType
Gets or sets the type of request that triggered the Toast close action.
Declaration
public string RequestType { get; set; }
Property Value
Type | Description |
---|---|
System.String | A string value indicating how the Toast close was initiated. Can be |
Remarks
This property provides information about what caused the Toast to close, such as user interaction, timeout expiration, or programmatic closure. Common values might include "User" for user-initiated closures, "Timeout" for automatic closures, or "Programmatic" for code-initiated closures. Understanding the request type helps in implementing different behaviors based on how the Toast was closed.