Add and Remove Items in Blazor Dropdown Menu Component

18 Dec 20231 minute to read

Dropdown Menu component can dynamically add or remove items using the AddItems and RemoveItems methods.

The following example illustrates how to add and remove items in Dropdown Menu component.

@using Syncfusion.Blazor.SplitButtons
@using Syncfusion.Blazor.Buttons

<SfDropDownButton Content="Paste Items" @ref="DropDownbuttonRef">
        <DropDownMenuItem Text="Paste"></DropDownMenuItem>
    <SfButton Content="Additem" IsPrimary="true" @onclick="addItem"></SfButton>

    <SfButton Content="Removeitem" IsPrimary="true" @onclick="removeItem"></SfButton>

@code {
    SfDropDownButton DropDownbuttonRef;

    private void addItem()

    private void removeItem()
    public List<DropDownMenuItem> dropdownbtnItems = new List<DropDownMenuItem>
        new DropDownMenuItem{ Text="Paste Special" },
        new DropDownMenuItem{ Text="Paste as Formula" },
        new DropDownMenuItem{ Text="Paste as Hyperlink" }

    public List<string> removeItems = new List<string>()

Adding Items in Blazor DropDownMenu