menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class ToastClickEventArgs - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class ToastClickEventArgs

    Specifies the event arguments for the Toast click event.

    Inheritance
    System.Object
    ToastClickEventArgs
    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

    true if the click event should be prevented; otherwise, false. The default value is false.

    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

    true if the Toast should be closed when clicked or tabbed; otherwise, false. The default value is false.

    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 null.

    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.

    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved