alexa
menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Class ListBoxTemplates<TItem>

    Provides template customization options for item and empty-state visual representation in a SfListBox<TValue, TItem>.

    Inheritance
    object
    ComponentBase
    OwningComponentBase
    SfOwningComponentBase
    ListBoxTemplates<TItem>
    Implements
    IComponent
    IHandleEvent
    IHandleAfterRender
    IDisposable
    Inherited Members
    ComponentBase.Assets
    ComponentBase.AssignedRenderMode
    ComponentBase.BuildRenderTree(RenderTreeBuilder)
    ComponentBase.DispatchExceptionAsync(Exception)
    ComponentBase.InvokeAsync(Action)
    ComponentBase.InvokeAsync(Func<Task>)
    ComponentBase.OnAfterRender(bool)
    ComponentBase.OnAfterRenderAsync(bool)
    ComponentBase.OnInitialized()
    ComponentBase.OnParametersSet()
    ComponentBase.OnParametersSetAsync()
    ComponentBase.RendererInfo
    ComponentBase.SetParametersAsync(ParameterView)
    ComponentBase.ShouldRender()
    ComponentBase.StateHasChanged()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    OwningComponentBase.IsDisposed
    OwningComponentBase.ScopedServices
    Namespace: Syncfusion.Blazor.DropDowns
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class ListBoxTemplates<TItem> : SfOwningComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable
    Type Parameters
    Name Description
    TItem

    The type of data modeled for each ListBox item (typically your item POCO).

    Remarks

    Use this class to supply custom markup or UI design for each item row (via ItemTemplate) and for the case when no data records are present (NoRecordsTemplate).

    Constructors

    ListBoxTemplates()

    Declaration
    public ListBoxTemplates()

    Properties

    ItemTemplate

    Gets or sets the template used for rendering each item in the SfListBox<TValue, TItem>. Set this to create a custom layout or appearance for item rows.

    Declaration
    [Parameter]
    public RenderFragment<TItem> ItemTemplate { get; set; }
    Property Value
    Type
    RenderFragment<TItem>
    Remarks

    Implement this template to style, reformat, or include additional content for every row of the ListBox. TItem supplies your bound data model (as the context).

    Examples

    This example creates an item template displaying a custom property:

    <SfListBox Value="@value" DataSource="@vehicleData" TValue="string[]" TItem="ListItem">
        <ListBoxFieldSettings Text="Text" Value="ID"></ListBoxFieldSettings>
        <ListBoxTemplates TItem="ListItem">
            <ItemTemplate>
                <div class="list-wrapper">
                   <span class="text">@((context as ListItem).Text)</span>
               </div>
           </ItemTemplate>
       </ListBoxTemplates>
    </SfListBox>

    NoRecordsTemplate

    Gets or sets the template that is displayed in the ListBox when no records are found. Use to customize the "no results found" UI.

    Declaration
    [Parameter]
    public RenderFragment NoRecordsTemplate { get; set; }
    Property Value
    Type
    RenderFragment
    Remarks

    Useful for scenarios where you wish to display user guidance or custom messages when the ListBox data set is empty or a search/filter yields no results.

    Examples

    This example creates a customized "No Records" message:

    <SfListBox Value="@value" DataSource="@vehicleData" TValue="string[]" TItem="ListItem">
        <ListBoxFieldSettings Text="Text" Value="ID"></ListBoxFieldSettings>
        <ListBoxTemplates TItem="ListItem">
            <NoRecordsTemplate>
                <div class="no-rec-template">
                   <span class="text">No Records Found</span>
               </div>
           </NoRecordsTemplate>
       </ListBoxTemplates>
    </SfListBox>

    Methods

    Dispose(bool)

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing
    Overrides
    OwningComponentBase.Dispose(bool)

    OnInitializedAsync()

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    Type
    Task
    Overrides
    ComponentBase.OnInitializedAsync()

    Implements

    IComponent
    IHandleEvent
    IHandleAfterRender
    IDisposable
    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved