Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxAccordion.SelectItem(Func<IAccordionItemInfo, Boolean>) Method

Selects the specified item.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public void SelectItem(
    Func<IAccordionItemInfo, bool> predicate
)

#Parameters

Name Type Description
predicate Func<IAccordionItemInfo, Boolean>

A delegate method that specifies a particular item.

#Remarks

If item selection is enabled, you can use the SelectItem method to select an item from code. This method does not select the specified item in bound mode if Load Child Items on Demand mode is enabled and the item is not loaded yet. If none of the items meet the specified condition, the component does not clear selection. Call the ClearSelection() method to deselect items.

The following code snippet implements the selection button:

razor
<DxAccordion @ref="MyAccordion" SelectionMode="NavigationSelectionMode.Single">
    <Items>
        <DxAccordionItem Text="Shapes">
            <Items>
                <DxAccordionItem Text="Circle" />
                <DxAccordionItem Text="Square" />
            </Items>
        </DxAccordionItem>
        <DxAccordionItem Text="Templates" />
    </Items>
</DxAccordion>

<DxButton Click="@OnClick">Select item</DxButton>

@code {
    DxAccordion MyAccordion;
    void OnClick() => MyAccordion.SelectItem(x => x.Text == "Templates");
}

See Also