menu

Blazor

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

    Show / Hide Table of Contents

    Class ListBoxTemplates<TItem>

    Specifies templates like ItemTemplate and NoRecordsTemplate for list items in the listbox.

    Inheritance
    System.Object
    ListBoxTemplates<TItem>
    Namespace: Syncfusion.Blazor.DropDowns
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class ListBoxTemplates<TItem> : OwningComponentBase
    Type Parameters
    Name
    TItem

    Constructors

    ListBoxTemplates()

    Declaration
    public ListBoxTemplates()

    Properties

    ItemTemplate

    Gets or sets the template used for the visual representation of each item in the SfListBox<TValue, TItem>.

    Declaration
    public RenderFragment<TItem> ItemTemplate { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.RenderFragment<TItem>
    Examples

    The below code example, showcases a item template in a SfListBox<TValue, TItem>.

    <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>
    @code{
        private string[] value= new string[] { "List-01"};
        private 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"}
        }
        public class ListItem
        {
            public string Text { get; set; }
            public string ID { get; set; }
         }
    }

    NoRecordsTemplate

    Gets or sets the template used for the visual representation of the No Record Found element in the SfListBox<TValue, TItem>.

    Declaration
    public RenderFragment NoRecordsTemplate { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.RenderFragment
    Examples

    The below code example, showcases a no record template in a SfListBox<TValue, TItem>.

    <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>
    @code{
        private string[] value= new string[] { "List-01"};
        private 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"}
        }
        public class ListItem
        {
            public string Text { get; set; }
            public string ID { get; set; }
         }
    }

    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
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved