menu

Xamarin.Forms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class AccordionItem - Xamarin.Forms API Reference | Syncfusion

    Show / Hide Table of Contents

    Class AccordionItem

    A SfAccordion class that provides a way to host a customizable header and content part as compound view. The content part gets expanded upon tapping the header part of the AccordionItem.

    Inheritance
    System.Object
    AccordionItem
    Implements
    System.IDisposable
    Namespace: Syncfusion.XForms.Accordion
    Assembly: Syncfusion.Expander.XForms.dll
    Syntax
    public class AccordionItem : View, IDisposable, IThemeElement
    Remarks

    The Accordion is a vertically collapsible content panel that displays one or more AccordionItem at a time within the available space. There are options to expand below or above the header. Also, you can customize to auto scroll an item upon expanding based on your requirement.

    Constructors

    AccordionItem()

    Initializes a new instance of the AccordionItem class.

    Declaration
    public AccordionItem()

    Fields

    ContentProperty

    Identifies the Content bindable property.

    Declaration
    public static readonly BindableProperty ContentProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty

    HeaderBackgroundColorProperty

    Identifies the HeaderBackgroundColor bindable property.

    Declaration
    public static readonly BindableProperty HeaderBackgroundColorProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty

    HeaderProperty

    Identifies the Header bindable property.

    Declaration
    public static readonly BindableProperty HeaderProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty

    IconColorProperty

    Identifies the IconColor bindable property.

    Declaration
    public static readonly BindableProperty IconColorProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty

    IsExpandedProperty

    Identifies the IsExpanded bindable property.

    Declaration
    public static readonly BindableProperty IsExpandedProperty
    Field Value
    Type
    Xamarin.Forms.BindableProperty

    Properties

    Content

    Gets or sets any kind of customizable visual element that can be loaded as content part of the AccordionItem. The default value is null which displays an empty space when expanded.

    Declaration
    public View Content { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.View

    By default, the content value is null.

    Remarks

    This allows you to load any kind of building blocks of user interfaces that to be loaded as the content part of the AccordionItem. This is a bindable property.

    See Also
    https://help.syncfusion.com/xamarin/accordion/getting-started?cs-save-lang=1cs-lang=xaml#defining-accordion-items

    Header

    Gets or sets a visual element that can be loaded as header part of the AccordionItem. By default, the header loads in a built-in label for which the text can be customized using localized string.

    Declaration
    public View Header { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.View

    By default, the header view value is null.

    Remarks

    This allows you to load any kind of building blocks of user interfaces that to be loaded as the header part of the AccordionItem.This is a bindable property.

    See Also
    https://help.syncfusion.com/xamarin/accordion/getting-started?cs-save-lang=1cs-lang=xaml#defining-accordion-items

    HeaderBackgroundColor

    Gets or sets the background color for the accordion header item.

    Declaration
    public Color HeaderBackgroundColor { get; set; }
    Property Value
    Type
    Xamarin.Forms.Color
    Examples
    SfAccordion accordion;
    public MainPage()
    {
        InitializeComponent();
        InitializeAccordionItems();
        this.Content = accordion;
    }
    
    private void InitializeAccordionItems()
    {
        accordion = new SfAccordion();
        accordion.Items.Add(GenerateAccordionItem());
    }
    
    public AccordionItem GenerateAccordionItem()
    {
        var item = new AccordionItem();
        item.HeaderBackgroundColor = Color.Pink;
        return item;
    }

    IconColor

    Gets or sets the icon color in the header of the accordion item.

    Declaration
    public Color IconColor { get; set; }
    Property Value
    Type
    Xamarin.Forms.Color
    Examples
    expander.Items.IconColor = Color.Grey;

    IsExpanded

    Gets or sets a value indicating whether the AccordionItem is in expanded state or collapsed state.

    Declaration
    public bool IsExpanded { get; set; }
    Property Value
    Type Description
    System.Boolean

    The default value is false and by default, the accordion item is in collapsed state.

    Remarks

    This allows you to control and expanded and collapsed state of an AccordionItem through user interaction or programmatically. This is bindable property.

    Examples
    accordion.IsExpanded = false;

    Methods

    ChangeVisualState()

    Helps to trigger the VisualState initially when View is loaded.

    Declaration
    protected override void ChangeVisualState()

    Dispose()

    Disposes of all the allocated resources to free up space.

    Declaration
    public void Dispose()

    Dispose(Boolean)

    Disposes all the objects in the AccordionItem.

    Declaration
    protected virtual void Dispose(bool isDisposing)
    Parameters
    Type Name Description
    System.Boolean isDisposing

    Value indicating whether to dispose the objects or not.

    OnBindingContextChanged()

    Notifies the change in BindingContext for the accordion.

    Declaration
    protected override void OnBindingContextChanged()

    Implements

    System.IDisposable

    See Also

    https://help.syncfusion.com/xamarin/accordion/getting-started?cs-save-lang=1cs-lang=xaml#defining-accordion-items
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved