Class TimePickerEvents<TValue>
Configures the event handlers for the SfTimePicker<TValue> component, allowing you to respond to various user interactions and component lifecycle events.
Inheritance
Namespace: Syncfusion.Blazor.Calendars
Assembly: Syncfusion.Blazor.dll
Syntax
public class TimePickerEvents<TValue> : OwningComponentBase
Type Parameters
Name | Description |
---|---|
TValue | Specifies the data type of the value bound to the TimePicker. |
Remarks
The TimePickerEvents
component is used within a SfTimePicker<TValue> to define callback methods for events such as value changes, focus, blur, and popup interactions.
Constructors
TimePickerEvents()
Declaration
public TimePickerEvents()
Properties
Blur
Gets or sets an event callback that is triggered 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<> that is invoked when the component loses focus. The callback receives a BlurEventArgs. |
Remarks
This event can be used to perform actions when the user navigates away from the TimePicker component.
Examples
<SfTimePicker TValue="DateTime?">
<TimePickerEvents TValue = "DateTime?" Blur="@OnBlur" />
</SfTimePicker>
@code{
private void OnBlur(BlurEventArgs args)
{
// Your logic here
}
}
Cleared
Gets or sets an event callback that is triggered when the component's 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<> that is invoked when the clear button is clicked. The callback receives a ClearedEventArgs. |
Remarks
This event is only applicable if the ShowClearButton property is set to true
.
Examples
<SfTimePicker TValue="DateTime?" ShowClearButton="true">
<TimePickerEvents TValue = "DateTime?" Cleared="@OnCleared" />
</SfTimePicker>
@code{
private void OnCleared(ClearedEventArgs args)
{
// Your logic here
}
}
Created
Gets or sets an event callback that is triggered 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<> that is invoked when the component is first rendered. |
Remarks
This event is useful for performing one-time initialization actions after the component has been rendered.
Examples
<SfTimePicker TValue="DateTime?">
<TimePickerEvents TValue="DateTime?" Created="@OnCreated" />
</SfTimePicker>
@code {
private void OnCreated(object args)
{
// Your logic here
}
}
Destroyed
Gets or sets an event callback that is triggered 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<> that is invoked when the component is being removed from the DOM. |
Remarks
This event is useful for performing cleanup operations before the component is completely removed.
Examples
<SfTimePicker TValue="DateTime?">
<TimePickerEvents TValue = "DateTime?" Destroyed="@OnDestroyed" />
</SfTimePicker>
@code{
private void OnDestroyed(object args)
{
// Your logic here
}
}
Focus
Gets or sets an event callback that is triggered when the component gains focus.
Declaration
public EventCallback<FocusEventArgs> Focus { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<FocusEventArgs> | An Microsoft.AspNetCore.Components.EventCallback<> that is invoked when the component receives focus. The callback receives a FocusEventArgs. |
Remarks
This event is useful for performing actions when the user starts interacting with the TimePicker.
Examples
<SfTimePicker TValue="DateTime?">
<TimePickerEvents TValue = "DateTime?" Focus="@OnFocus" />
</SfTimePicker>
@code{
private void OnFocus(FocusEventArgs args)
{
// Your logic here
}
}
OnClose
Gets or sets an event callback that is triggered when the time suggestion popup is closed.
Declaration
public EventCallback<PopupEventArgs> OnClose { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<PopupEventArgs> | An Microsoft.AspNetCore.Components.EventCallback<> that is invoked when the popup closes. The callback receives a PopupEventArgs. |
Remarks
You can prevent the popup from closing by setting the Cancel property to true
within the event handler.
Examples
<SfTimePicker TValue="DateTime?">
<TimePickerEvents TValue="DateTime?" OnClose="@PopupClose" />
</SfTimePicker>
@code{
private void PopupClose(PopupEventArgs args) {
args.Cancel = true;
}
}
OnItemRender
Gets or sets an event callback that is triggered while rendering each item in the time suggestion popup.
Declaration
public EventCallback<ItemEventArgs<TValue>> OnItemRender { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<ItemEventArgs<TValue>> | An Microsoft.AspNetCore.Components.EventCallback<> that is invoked for each list item. The callback receives an ItemEventArgs<T>. |
Remarks
This event allows for the customization of each time item, such as adding custom attributes or disabling specific times.
Examples
<SfTimePicker TValue="DateTime?">
<TimePickerEvents TValue="DateTime?" OnItemRender="@ItemRender" />
</SfTimePicker>
@code{
private void ItemRender(ItemEventArgs<DateTime?> args) {
Console.WriteLine(args.Text);
}
}
OnOpen
Gets or sets an event callback that is triggered when the time suggestion popup is opened.
Declaration
public EventCallback<PopupEventArgs> OnOpen { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<PopupEventArgs> | An Microsoft.AspNetCore.Components.EventCallback<> that is invoked when the popup opens. The callback receives a PopupEventArgs. |
Remarks
You can prevent the popup from opening by setting the Cancel property to true
within the event handler.
Examples
<SfTimePicker TValue="DateTime?">
<TimePickerEvents TValue="DateTime?" OnOpen="@PopupOpen" />
</SfTimePicker>
@code{
private void PopupOpen(PopupEventArgs args) {
args.Cancel = true;
}
}
Selected
Gets or sets an event callback that is triggered after a time value is selected from the popup.
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 a value is selected. The callback receives a SelectedEventArgs<T>. |
Remarks
This event provides the selected time value and can be used to perform actions immediately after a selection is made.
Examples
<SfTimePicker TValue="DateTime?">
<TimePickerEvents TValue="DateTime?" Selected="@ValueSelected" />
</SfTimePicker>
@code{
private void ValueSelected(SelectedEventArgs<DateTime?> args) {
Console.WriteLine(args.Value);
}
}
ValueChange
Gets or sets an event callback that is triggered when the value of the component is changed.
Declaration
public EventCallback<ChangeEventArgs<TValue>> ValueChange { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<ChangeEventArgs<TValue>> | An Microsoft.AspNetCore.Components.EventCallback<> that is invoked when the component's value changes. The callback receives a ChangeEventArgs<T>. |
Remarks
This event is fired when the user selects a time from the popup, or when the value is changed programmatically.
Examples
<SfTimePicker TValue="DateTime?">
<TimePickerEvents TValue="DateTime?" ValueChange="@ValueChange" />
</SfTimePicker>
@code{
private void ValueChange(ChangeEventArgs<DateTime?> args) {
Console.WriteLine(args.Value);
}
}
Methods
ComponentDispose(Boolean)
Disposes the component and cleans up its resources.
Declaration
protected void ComponentDispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | A boolean value indicating whether the component is being disposed. |
Remarks
This protected method is called to release managed resources and disconnect from the parent component.
OnInitializedAsync()
Initializes the component and establishes a connection with the parent SfTimePicker<TValue> component.
Declaration
protected override Task OnInitializedAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task that represents the asynchronous initialization process. |
Remarks
This method is part of the Blazor component lifecycle and is called when the component is first initialized.