Add and Remove Items in Blazor Dropdown Menu Component

7 Sep 20211 minute to read

Dropdown Menu component can be dynamically add or remove items using AddItems, RemoveItems method.

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>()

Output be like

Adding Items in Blazor DropDownMenu