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.GetSelectedItemInfo() Method

Returns information about the selected item.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public IAccordionItemInfo GetSelectedItemInfo()

#Returns

Type Description
IAccordionItemInfo

An object that contains information about the selected item.

#Remarks

The following code snippet expands a selected item if it has children:

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

@code {
    DxAccordion MyAccordion;
    void OnSelectionChanged(AccordionSelectionChangedEventArgs e) {
        MyAccordion.CollapseAll();
        MyAccordion.ExpandToItem((x) => x == e.SelectedItems.FirstOrDefault());
        if (MyAccordion.GetSelectedItemInfo().HasChildren) {
            MyAccordion.SetItemExpanded((x => x.Text == e.SelectedItems.FirstOrDefault()?.Text), true);
        }
    }
}
See Also