Class ListBoxEvents<TValue, TItem>
Declares the set of event callbacks exposed by SfListBox<TValue, TItem> for handling filtering, selection, drag-and-drop, creation, and more.
Inheritance
Namespace: Syncfusion.Blazor.DropDowns
Assembly: Syncfusion.Blazor.dll
Syntax
public class ListBoxEvents<TValue, TItem> : OwningComponentBase
Type Parameters
Name | Description |
---|---|
TValue | The type used to represent selected item values (e.g., |
TItem | The data type for items displayed in the ListBox (e.g., an entity or simple value). |
Remarks
Use these events to customize data requests, selection logic, UI feedback, and integration scenarios for SfListBox<TValue, TItem>.
Examples
This example demonstrates how to listen for creation, value changes, and filtering events in a ListBox:
<SfListBox @ref="ListBoxObj" DataSource="@vehicleData" TValue="string[]" TItem="ListItem">
<ListBoxFieldSettings Text="Text" Value="ID"></ListBoxFieldSettings>
<ListBoxEvents TValue="string[]" Created="OnCreated" ValueChange="OnValueChange" Filtering="OnFiltering"></ListBoxEvents>
</SfListBox>
@code {
SfListBox<string[], ListItem> ListBoxObj;
public List<ListItem> vehicleData = new List<ListItem> {
new ListItem { Text = "Hennessey Venom", ID = "List-01" },
new ListItem { Text = "Bugatti Chiron", ID = "List-02" },
new ListItem { Text = "Bugatti Veyron Super Sport", ID = "List-03" }
};
private Task OnCreated(object args) => ListBoxObj.SelectItemsAsync(Value, true);
private void OnValueChange(ListBoxChangeEventArgs<string[], ListItem> args) { /* React to selection changes */ }
private void OnFiltering(FilteringEventArgs args) { /* Custom filtering logic */ }
public class ListItem { public string Text {get;set;} public string ID {get;set;} }
}
Constructors
ListBoxEvents()
Declaration
public ListBoxEvents()
Properties
Created
Raised when the ListBox is fully initialized and ready for interaction.
Declaration
public EventCallback<object> Created { get; set; }
Property Value
Type |
---|
Microsoft.AspNetCore.Components.EventCallback<System.Object> |
Examples
private Task OnCreated(object args) { /* Additional setup after creation */ }
Destroyed
Raised when the ListBox is destroyed, letting you clean up state or subscriptions.
Declaration
public EventCallback<object> Destroyed { get; set; }
Property Value
Type |
---|
Microsoft.AspNetCore.Components.EventCallback<System.Object> |
DragStart
Triggered before starting to drag an item, enabling custom logic or cancellation.
Declaration
public EventCallback<DragEventArgs<TItem>> DragStart { get; set; }
Property Value
Type |
---|
Microsoft.AspNetCore.Components.EventCallback<DragEventArgs<TItem>> |
Remarks
Available only when AllowDragAndDrop is true
.
Dropped
Triggered after successful drop operation to let you respond to or process item movement.
Declaration
public EventCallback<DropEventArgs<TItem>> Dropped { get; set; }
Property Value
Type |
---|
Microsoft.AspNetCore.Components.EventCallback<DropEventArgs<TItem>> |
Remarks
Available only when AllowDragAndDrop is true
.
Filtering
Raised whenever the user enters text to filter or search ListBox items.
Declaration
public EventCallback<FilteringEventArgs> Filtering { get; set; }
Property Value
Type |
---|
Microsoft.AspNetCore.Components.EventCallback<FilteringEventArgs> |
Remarks
Available only when AllowFiltering is true
.
Examples
private void OnFiltering(FilteringEventArgs args) {
// Customize query for dynamic filtering
}
ListBoxItemKeyDown
Triggered when performing a keydown action in a ListBox item (e.g. for advanced keyboard handling).
Declaration
public EventCallback<ListBoxKeyDownEventArgs> ListBoxItemKeyDown { get; set; }
Property Value
Type |
---|
Microsoft.AspNetCore.Components.EventCallback<ListBoxKeyDownEventArgs> |
OnActionBegin
Invoked before fetching data from a remote server in the SfListBox<TValue, TItem>. Allows you to customize request parameters or cancel the request.
Declaration
public EventCallback<ActionBeginEventArgs> OnActionBegin { get; set; }
Property Value
Type |
---|
Microsoft.AspNetCore.Components.EventCallback<ActionBeginEventArgs> |
OnActionComplete
Invoked after data has been successfully fetched from a remote server.
Declaration
public EventCallback<ActionCompleteEventArgs<TItem>> OnActionComplete { get; set; }
Property Value
Type |
---|
Microsoft.AspNetCore.Components.EventCallback<ActionCompleteEventArgs<TItem>> |
OnActionFailure
Triggered when a data fetch from the server fails. Use to log or display errors.
Declaration
public EventCallback<object> OnActionFailure { get; set; }
Property Value
Type |
---|
Microsoft.AspNetCore.Components.EventCallback<System.Object> |
OnDrop
Triggered before dropping items onto the ListBox, allowing cancellation or custom drop behavior.
Declaration
public EventCallback<DropEventArgs<TItem>> OnDrop { get; set; }
Property Value
Type |
---|
Microsoft.AspNetCore.Components.EventCallback<DropEventArgs<TItem>> |
Remarks
Available only when AllowDragAndDrop is true
.
OnItemRender
Occurs before rendering each item in the ListBox, giving you the chance to customize item content or appearance.
Declaration
public EventCallback<BeforeItemRenderEventArgs<TItem>> OnItemRender { get; set; }
Property Value
Type |
---|
Microsoft.AspNetCore.Components.EventCallback<BeforeItemRenderEventArgs<TItem>> |
ValueChange
Triggered when the selected value(s) of the ListBox change.
Declaration
public EventCallback<ListBoxChangeEventArgs<TValue, TItem>> ValueChange { get; set; }
Property Value
Type |
---|
Microsoft.AspNetCore.Components.EventCallback<ListBoxChangeEventArgs<TValue, TItem>> |
Methods
Dispose(Boolean)
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
OnInitializedAsync()
Declaration
protected override Task OnInitializedAsync()
Returns
Type |
---|
System.Threading.Tasks.Task |