Class DatePickerEvents<TValue>
Provides events for the SfDatePicker<TValue> component, allowing you to handle value changes, focus, creation and destruction, and other interactions.
Inheritance
Namespace: Syncfusion.Blazor.Calendars
Assembly: Syncfusion.Blazor.dll
Syntax
public class DatePickerEvents<TValue> : OwningComponentBase
Type Parameters
Name | Description |
---|---|
TValue | Specifies the value type used by the SfDatePicker<TValue> component. |
Remarks
The DatePickerEvents<TValue> class allows developers to respond to a wide variety of user actions and lifecycle events in the SfDatePicker<TValue> component. These events enable detailed customization of value-change handling, popup behavior, calendar display, and individual day cell rendering.
Examples
The following demonstrates how to handle value changes and popup open event:
<SfDatePicker TValue="DateTime?">
<DatePickerEvents TValue="DateTime?" ValueChange="@OnValueChange" OnOpen="@OnPopupOpen" />
</SfDatePicker>
@code{
private void OnValueChange(ChangedEventArgs<DateTime?> args) {
// Handle value change
}
private void OnPopupOpen(PopupObjectArgs args) {
// Handle popup open
}
}
Constructors
DatePickerEvents()
Declaration
public DatePickerEvents()
Properties
Blur
Gets or sets the event callback that is invoked when the component loses focus.
Declaration
public EventCallback<BlurEventArgs> Blur { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<BlurEventArgs> | An Microsoft.AspNetCore.Components.EventCallback<> triggered when the input loses focus. |
Remarks
Use this event to perform custom logic when the input field loses focus, such as finalizing data entry or validation.
Cleared
Gets or sets the event callback that is invoked when the component value is cleared using the clear button.
Declaration
public EventCallback<ClearedEventArgs> Cleared { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<ClearedEventArgs> | An Microsoft.AspNetCore.Components.EventCallback<> triggered after the value is cleared by the user. |
Remarks
Use this event to handle actions, such as resetting dependent fields or updating state, after the DatePicker value is cleared.
Created
Gets or sets the event callback that is invoked when the component is created.
Declaration
public EventCallback<object> Created { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<System.Object> | An Microsoft.AspNetCore.Components.EventCallback triggered once the DatePicker component is created and ready for use. |
Remarks
Use this event to perform initialization or startup logic for the DatePicker.
Destroyed
Gets or sets the event callback that is invoked when the component is destroyed.
Declaration
public EventCallback<object> Destroyed { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<System.Object> | An Microsoft.AspNetCore.Components.EventCallback triggered just before the DatePicker component is removed from the UI. |
Remarks
Clean up resources or perform any necessary teardown logic inside this event.
Focus
Gets or sets the event callback that is invoked when the component receives focus.
Declaration
public EventCallback<FocusEventArgs> Focus { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<FocusEventArgs> | An Microsoft.AspNetCore.Components.EventCallback<> triggered when the component input receives keyboard or mouse focus. |
Remarks
Use this event to respond to focus changes or update UI highlights as required.
Navigated
Gets or sets the event callback that is invoked when the Calendar is navigated to another level or within the same view.
Declaration
public EventCallback<NavigatedEventArgs> Navigated { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<NavigatedEventArgs> | An Microsoft.AspNetCore.Components.EventCallback<> triggered each time the view changes between year, month, or decade. |
Remarks
Use this event to capture or act on navigation between the Calendar views, such as customizing data for a specific view.
Examples
<SfDatePicker TValue="DateTime?">
<DatePickerEvents TValue="DateTime?" Navigated="@ViewNavigated" />
</SfDatePicker>
@code{
private void ViewNavigated(NavigatedEventArgs args) {
Console.WriteLine(args.View);
}
}
OnClose
Gets or sets the event callback that is invoked when the popup is closed.
Declaration
public EventCallback<PopupObjectArgs> OnClose { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<PopupObjectArgs> | An Microsoft.AspNetCore.Components.EventCallback<> triggered when the popup is closed, either by user action or programmatically. |
Remarks
Use this event to execute custom logic after the popup closes. You can cancel closing through the event argument.
Examples
<SfDatePicker TValue="DateTime?">
<DatePickerEvents TValue="DateTime?" OnClose="@PopupClose" />
</SfDatePicker>
@code{
private void PopupClose(PopupObjectArgs args) {
args.Cancel = true;
}
}
OnOpen
Gets or sets the event callback that is invoked when the popup is opened.
Declaration
public EventCallback<PopupObjectArgs> OnOpen { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<PopupObjectArgs> | An Microsoft.AspNetCore.Components.EventCallback<> triggered when the picker popup is opened. |
Remarks
Use this event to customize the popup prior to it being displayed, such as modifying content or cancelling the open action.
Examples
<SfDatePicker TValue="DateTime?">
<DatePickerEvents TValue="DateTime?" OnOpen="@PopupOpen" />
</SfDatePicker>
@code{
private void PopupOpen(PopupObjectArgs args) {
args.Cancel = true;
}
}
OnRenderDayCell
Gets or sets the event callback that is invoked when each day cell of the Calendar is rendered.
Declaration
public EventCallback<RenderDayCellEventArgs> OnRenderDayCell { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<RenderDayCellEventArgs> | An Microsoft.AspNetCore.Components.EventCallback<> triggered while rendering each day cell in the Calendar Popup. |
Remarks
Use this event to customize the appearance and content of individual day cells in the Calendar.
Examples
<SfDatePicker TValue="DateTime?">
<DatePickerEvents TValue="DateTime?" OnRenderDayCell="CellRendered" />
</SfDatePicker>
@code{
private void CellRendered(RenderDayCellEventArgs args) {
args.CellData.ClassList = "e-custom-style";
}
}
Selected
Gets or sets the event callback that is invoked after selecting the value from the component.
Declaration
public EventCallback<SelectedEventArgs<TValue>> Selected { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<SelectedEventArgs<TValue>> | An Microsoft.AspNetCore.Components.EventCallback<> of type |
Remarks
This event occurs after the user selects a value from the Calendar, but before the value is set. Use this event for custom actions such as formatting or validation prior to assignment.
Examples
<SfDatePicker TValue="DateTime?">
<DatePickerEvents TValue="DateTime?" Selected="@ValueSelected" />
</SfDatePicker>
@code{
private void ValueSelected(SelectedEventArgs<DateTime?> args) {
Console.WriteLine(args.Value);
}
}
ValueChange
Gets or sets the event callback that is invoked when the component value is changed.
Declaration
public EventCallback<ChangedEventArgs<TValue>> ValueChange { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<ChangedEventArgs<TValue>> | An Microsoft.AspNetCore.Components.EventCallback<> of type |
Remarks
Use this event to respond to changes to the input value, either from user interaction or programmatic changes. The event provides the new value in the event arguments.
Examples
<SfDatePicker TValue="DateTime?">
<DatePickerEvents TValue="DateTime?" ValueChange="@ValueChange" />
</SfDatePicker>
@code{
private void ValueChange(ChangedEventArgs<DateTime?> args) {
Console.WriteLine(args.Value);
}
}
Methods
OnInitializedAsync()
Called during the initial rendering of the component, allowing the event wiring to be set up for the parent SfDatePicker<TValue>.
Declaration
protected override Task OnInitializedAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |
Remarks
This method assigns this instance of DatePickerEvents<TValue> to the parent SfDatePicker<TValue>, allowing the parent to raise events declared in this component.