ListBox Templates
The ListBox features templates that allow you to customize the component rendering and styling. This article describes all available templates and explains how to use them.
Item Template
The ListBox ItemTemplate enables you to change the default HTML output and CSS styling of the data items.
The <ItemTemplate> tag is a Blazor RenderFragment. It exposes a context variable that is the current data item object and you can access its properties directly without casting.
No Data Template
The ListBox shows the NoDataTemplate when there are no items in the component Data.
Example
The following example shows how to place a Button inside the NoDataTemplate, which adds new items to the ListBox. Another option for such functionality is to use a custom toolbar button.
Always Rebind() the ListBox after making programmatic changes to its Data.
Using ListBox templates