Class ToastClickEventArgs
Specifies the event arguments for the Toast click event.
Inheritance
Namespace: Syncfusion.Blazor.Notifications
Assembly: Syncfusion.Blazor.dll
Syntax
public class ToastClickEventArgs : Object
Remarks
This class provides data for the event that is raised when a Toast notification is clicked or receives keyboard focus. It allows you to control the click behavior, prevent the default action, and determine whether the Toast should be closed on interaction.
Examples
<SfToast @ref="ToastRef">
<ToastEvents TValue="ToastModel" OnClick="@OnToastClick"></ToastEvents>
</SfToast>
private void OnToastClick(ToastClickEventArgs args)
{
// Prevent default click behavior
args.Cancel = true;
// Control whether Toast closes on click
args.ClickToClose = false;
// Custom action based on toast content
if (args.Options?.Title == "Warning")
{
// Handle warning toast click
ShowDetailedWarning();
}
}
Constructors
ToastClickEventArgs()
Declaration
public ToastClickEventArgs()
Properties
Cancel
Gets or sets a value indicating whether the Toast click event should be cancelled.
Declaration
public bool Cancel { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
Setting this property to true
prevents the default click behavior from executing.
This is useful when you want to implement custom click handling logic without triggering the Toast's built-in click responses.
ClickToClose
Gets or sets a value indicating whether the Toast should be closed when clicked or focused.
Declaration
public bool ClickToClose { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
This property controls the auto-close behavior of the Toast when user interacts with it through clicking or keyboard navigation.
When set to true
, the Toast will automatically close after the click event is processed.
This is commonly used for acknowledgment-type notifications where user interaction indicates the message has been read.
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 clicked Toast notification. Can be |
Remarks
This property provides access to the complete configuration of the Toast that was clicked. You can use this information to implement context-specific click handling, access the Toast's content, title, or other properties, and make decisions about subsequent actions based on the Toast's characteristics.