menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class CalendarEvents<TValue> - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class CalendarEvents<TValue>

    Provides a set of event callbacks for handling various lifecycle and interaction events in the SfCalendar<TValue> component.

    Inheritance
    System.Object
    CalendarEvents<TValue>
    Namespace: Syncfusion.Blazor.Calendars
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class CalendarEvents<TValue> : OwningComponentBase
    Type Parameters
    Name Description
    TValue

    Specifies the type of the value bound to the calendar, such as DateTime or DateTime?.

    Remarks

    The CalendarEvents<TValue> class enables developers to customize calendar behavior by responding to value changes, date selection, navigation events, rendering of day cells, creation, and destruction events at the component level.

    Examples

    The following example demonstrates configuring event callbacks for a calendar.

    <SfCalendar TValue="DateTime?">
        <CalendarEvents TValue="DateTime?" ValueChange="@ValueChange" Selected="@ValueSelected" DeSelected="@ValueDeselected" Navigated="@ViewNavigated" OnRenderDayCell="@CellRendered" Created="@OnCreated" Destroyed="@OnDestroyed" />
    </SfCalendar>
    @code {
        private void ValueChange(ChangedEventArgs<DateTime?> args) { /* ... */ }
        private void ValueSelected(SelectedEventArgs<DateTime?> args) { /* ... */ }
        private void ValueDeselected(DeSelectedEventArgs<DateTime?> args) { /* ... */ }
        private void ViewNavigated(NavigatedEventArgs args) { /* ... */ }
        private void CellRendered(RenderDayCellEventArgs args) { /* ... */ }
        private void OnCreated(object args) { /* ... */ }
        private void OnDestroyed(object args) { /* ... */ }
    }

    Constructors

    CalendarEvents()

    Declaration
    public CalendarEvents()

    Properties

    Created

    Gets or sets an event callback that is invoked when the calendar component is created and initialized.

    Declaration
    public EventCallback<object> Created { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.Object>

    An Microsoft.AspNetCore.Components.EventCallback<> of type object that is triggered after the component is created and fully initialized. The callback receives an object containing creation details.

    Remarks

    This event is useful for executing code after the calendar's resources have been fully allocated and rendered.

    Examples
    <SfCalendar TValue="DateTime?">
        <CalendarEvents TValue="DateTime?" Created="@OnCreated"/>
    </SfCalendar>
    @code {
        private void OnCreated(object args) {
            Console.WriteLine("Calendar created.");
        }
    }

    DeSelected

    Gets or sets an event callback that is invoked after deselecting a value in the calendar.

    Declaration
    public EventCallback<DeSelectedEventArgs<TValue>> DeSelected { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<DeSelectedEventArgs<TValue>>

    An Microsoft.AspNetCore.Components.EventCallback<> that is invoked when a value is deselected. The callback receives a DeSelectedEventArgs<T> instance providing details of the deselected date.

    Remarks

    This event is only triggered when the IsMultiSelection property is enabled, allowing multiple date selection and deselection in the calendar.

    Examples
    <SfCalendar TValue="DateTime?" IsMultiSelection="true">
        <CalendarEvents TValue="DateTime?" DeSelected="@ValueDeselected"/>
    </SfCalendar>
    @code {
        private void ValueDeselected(DeSelectedEventArgs<DateTime?> args) {
            Console.WriteLine($"Deselected value: {args.Value}");
        }
    }

    Destroyed

    Gets or sets an event callback that is invoked when the calendar component is disposed and destroyed.

    Declaration
    public EventCallback<object> Destroyed { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.Object>

    An Microsoft.AspNetCore.Components.EventCallback<> of type object that is triggered during component disposal. The callback receives an object providing destruction context.

    Remarks

    Use this event to perform cleanup or release resources associated with the calendar when it is destroyed.

    Examples
    <SfCalendar TValue="DateTime?">
        <CalendarEvents TValue="DateTime?" Destroyed="@OnDestroyed"/>
    </SfCalendar>
    @code {
        private void OnDestroyed(object args) {
            Console.WriteLine("Calendar destroyed.");
        }
    }

    Navigated

    Gets or sets an event callback that is invoked after the calendar is navigated to another level or within the same level of the calendar view.

    Declaration
    public EventCallback<NavigatedEventArgs> Navigated { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<NavigatedEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered after navigation in the calendar. The callback receives a NavigatedEventArgs instance describing the navigation context.

    Remarks

    Use this event to track and respond to changes in the calendar's current view, such as when switching between months, years, or decades.

    Examples
    <SfCalendar TValue="DateTime?">
        <CalendarEvents TValue="DateTime?" Navigated="@ViewNavigated" />
    </SfCalendar>
    @code {
        private void ViewNavigated(NavigatedEventArgs args) {
            Console.WriteLine($"Current view: {args.View}");
        }
    }

    OnRenderDayCell

    Gets or sets an event callback that is invoked as each calendar day cell is rendered.

    Declaration
    public EventCallback<RenderDayCellEventArgs> OnRenderDayCell { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<RenderDayCellEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered when a day cell is rendered in the calendar. The callback receives a RenderDayCellEventArgs providing details for customizing the cell appearance.

    Remarks

    This event allows customizing the visual appearance or properties of individual day cells as they are rendered in the calendar UI.

    Examples
    <SfCalendar TValue="DateTime?">
        <CalendarEvents TValue="DateTime?" OnRenderDayCell="@CellRendered" />
    </SfCalendar>
    @code {
        private void CellRendered(RenderDayCellEventArgs args) {
            args.CellData.ClassList = "e-custom-style";
        }
    }

    Selected

    Gets or sets an event callback that is invoked after one or more date values are selected in the calendar.

    Declaration
    public EventCallback<SelectedEventArgs<TValue>> Selected { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<SelectedEventArgs<TValue>>

    An Microsoft.AspNetCore.Components.EventCallback<> that is invoked when dates are selected. The callback receives a SelectedEventArgs<T> instance containing the information about the selected value(s).

    Remarks

    This event is raised after a date or multiple dates are selected by the user via the calendar UI or through code.

    Examples
    <SfCalendar TValue="DateTime?">
        <CalendarEvents TValue="DateTime?" Selected="@ValueSelected"/>
    </SfCalendar>
    @code {
        private void ValueSelected(SelectedEventArgs<DateTime?> args) {
            Console.WriteLine($"Selected value: {args.Value}");
        }
    }

    ValueChange

    Gets or sets an event callback that is invoked when the Values property changes.

    Declaration
    public EventCallback<ChangedEventArgs<TValue>> ValueChange { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<ChangedEventArgs<TValue>>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered when the calendar values are changed. The callback receives an instance of ChangedEventArgs<T> containing the new value and other details.

    Remarks

    Use this event to respond to changes in the selected dates when interacting with the calendar, such as via UI input or programmatic assignment.

    Examples
    <SfCalendar TValue="DateTime?">
        <CalendarEvents TValue="DateTime?" ValueChange="@ValueChange"/>
    </SfCalendar>
    @code {
        private void ValueChange(ChangedEventArgs<DateTime?> args) {
            Console.WriteLine($"Changed value: {args.Value}");
        }
    }

    Methods

    OnInitializedAsync()

    Executes custom logic on initial rendering of the calendar component.

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation.

    Remarks

    This method sets the CalendarEvents<TValue> instance into the parent SfCalendar<TValue> component for event binding. It is called as part of the Blazor component lifecycle.

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