Class SfAccordion
A SfAccordion class provides a way to display the information in a vertically stacked list of items. This is a collection of collapsed and expanded AccordionItem.
Inheritance
Implements
Namespace: Syncfusion.XForms.Accordion
Assembly: Syncfusion.Expander.XForms.dll
Syntax
public class SfAccordion : Layout<View>, IDisposable, IParentThemeElement, 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
SfAccordion()
Initializes a new instance of the SfAccordion class and initialize the default values of this members.
Declaration
public SfAccordion()
Fields
AnimationDurationProperty
Identifies the AnimationDuration bindable property.
Declaration
public static readonly BindableProperty AnimationDurationProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
Remarks
This bindable property is read-only.
AnimationEasingProperty
Identifies the AnimationEasing bindable property.
Declaration
public static readonly BindableProperty AnimationEasingProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
Remarks
This bindable property is read-only.
AutoScrollPositionProperty
Identifies the AutoScrollPosition bindable property.
Declaration
public static readonly BindableProperty AutoScrollPositionProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
Remarks
This bindable property is read-only.
DynamicSizeModeProperty
Identifies the DynamicSizeMode bindable property.
Declaration
public static readonly BindableProperty DynamicSizeModeProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
ExpandDirectionProperty
Identifies the Syncfusion.XForms.Accordion.SfAccordion.ExpandDirection bindable property.
Declaration
public static readonly BindableProperty ExpandDirectionProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
Remarks
This bindable property is read-only.
ExpandModeProperty
Identifies the ExpandMode bindable property.
Declaration
public static readonly BindableProperty ExpandModeProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
Remarks
This bindable property is read-only.
HeaderIconPositionProperty
Identifies the HeaderIconPosition bindable property.
Declaration
public static readonly BindableProperty HeaderIconPositionProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
Remarks
This bindable property is read-only.
ItemSpacingProperty
Identifies the ItemSpacing bindable property.
Declaration
public static readonly BindableProperty ItemSpacingProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
Remarks
This bindable property is read-only.
ItemsProperty
Identifies the Items bindable property.
Declaration
public static readonly BindableProperty ItemsProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
Remarks
This bindable property is read-only.
Properties
AnimationDuration
Gets or sets a value indicating the animation duration for the expanding and collapsing of AccordionItem.
Declaration
public double AnimationDuration { get; set; }
Property Value
Type | Description |
---|---|
System.Double | By default, the animation duration is 150 milliseconds. |
Remarks
This property sets the length of time that an animation takes to complete one cycle.
Examples
accordion.AnimationDuration = 150;
AnimationEasing
Gets or sets the AnimationEasing that specifies the rate of change of parameter over time or animation style of the AccordionItem.
Declaration
public AnimationEasing AnimationEasing { get; set; }
Property Value
Type | Description |
---|---|
AnimationEasing | By default,the easing funtion is Linear.Set this property as None to disable the animation for accordion item. |
Remarks
This a way to adjust an animation’s rate of change and its allows transitioning elements to speed up and slow down, rather than moving at a constant rate.
Examples
accordion.AnimationEasing = Syncfusion.XForms.Expander.AnimationEasing.SinOut;
AutoScrollPosition
Gets or sets a value to specify the scroll position of the expanded AccordionItem. This represents a visible portion of the accordion item.
Declaration
public AutoScrollPosition AutoScrollPosition { get; set; }
Property Value
Type | Description |
---|---|
AutoScrollPosition | By default, The auto scroll position is MakeVisible. |
Remarks
This property is used to scroll the expanded accordion item into visible or top. If expand the out of view accordion item with programmatic means automatically scroll into the view with use of MakeVisible. or Top. types.
Examples
To be added
DynamicSizeMode
Gets or sets the value indicating whether to update accordion items based on dynamic size changes of Header view and Content view.
Declaration
public DynamicSizeMode DynamicSizeMode { get; set; }
Property Value
Type |
---|
DynamicSizeMode |
Examples
accordion.DynamicSizeMode = DynamicSizeMode.Content | DynamicSizeMode.Header;
ExpandMode
Gets or sets a value that indicates whether an end-user can expand single or multiple accordion items.
Declaration
public ExpandMode ExpandMode { get; set; }
Property Value
Type | Description |
---|---|
ExpandMode | The value that organize the expand and collapse state of the accordion items. The default value is Single. |
Remarks
The value specifies how the AccordionItem are displayed when opened and closed.
Examples
accordion.ExpandMode = Syncfusion.XForms.Accordion.ExpandMode.Multiple;
HeaderIconPosition
Gets or sets the IconPosition that indicates where to show the HeaderIconTemplate in the AccordionItem.
Declaration
public IconPosition HeaderIconPosition { get; set; }
Property Value
Type | Description |
---|---|
IconPosition | By default,The header icon position is End. |
Remarks
The position indicates that where to show the HeaderIconTemplate in the AccordionItem's header.
Examples
accordion.ExpandDirection = Syncfusion.XForms.Accordion.ExpandDirection.Down;
Items
Gets or sets the collection of AccordionItem with support for header and content. Customize the header and footer of each accordion item.
Declaration
public ObservableCollection<AccordionItem> Items { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.ObjectModel.ObservableCollection<AccordionItem> | The value indicates observable collection of the accordion item. The default value is null. |
Remarks
The collection of AccordionItem with support for header and content that is entirely customizable for each accordion item. Add, remove or update an accordion item at runtime that will be refreshed in view responsively.
See Also
ItemSpacing
Gets or sets a value that specifies the vertical spacing between the accordion items. The default value is 6.0d.
Declaration
public double ItemSpacing { get; set; }
Property Value
Type | Description |
---|---|
System.Double | Specifies the vertical spacing between the accordion items. The default value is 6.0d. |
Remarks
A value that specifies the vertical spacing between the accordion items. The default value is 6.0d.
Examples
accordion.ItemSpacing = 8.0d;
Methods
BringIntoView(AccordionItem)
Attempts to bring the accordion item into view by scrolling.
Declaration
public void BringIntoView(AccordionItem item)
Parameters
Type | Name | Description |
---|---|---|
AccordionItem | item | Represents the AccordionItem to scroll. |
Dispose()
Disposes of all the allocated resources and clean up memory.
Declaration
public void Dispose()
Dispose(Boolean)
Disposes of all the allocated resources and clean up memory if the parameter is true.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Represents the boolean value for disposing objects. |
LayoutChildren(Double, Double, Double, Double)
Layout the child elements.
Declaration
protected override void LayoutChildren(double x, double y, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.Double | x | Represents the x position. |
System.Double | y | Represents the y position. |
System.Double | width | Represents the width of the child element. |
System.Double | height | Represents the height of the child element. |
OnChildAdded(Element)
Add child elements.
Declaration
protected override void OnChildAdded(Element child)
Parameters
Type | Name | Description |
---|---|---|
Xamarin.Forms.Element | child | Represents the child element to be added. |
OnChildMeasureInvalidated()
Method raises when the content size is changed at runtime.
Declaration
protected override void OnChildMeasureInvalidated()
OnSizeAllocated(Double, Double)
Allocates the size of item elements.
Declaration
protected override void OnSizeAllocated(double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.Double | width | The new width of the element. |
System.Double | height | The new height of the element. |
RaiseCollapsedEvent(Int32)
Raises the Collapsed event with ExpandedAndCollapsedEventArgs.
Declaration
protected void RaiseCollapsedEvent(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Represents the index. |
RaiseCollapsingEvent(Int32)
Raises the Collapsing event with ExpandingAndCollapsingEventArgs.
Declaration
protected bool RaiseCollapsingEvent(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Represents the index. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if collapsing event is not triggered else inverse of ExpandingAndCollapsingEventArgs.Cancel value. |
See Also
RaiseExpandedEvent(Int32)
Raises the Expanded event with ExpandedAndCollapsedEventArgs.
Declaration
protected void RaiseExpandedEvent(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Represents the index. |
RaiseExpandingEvent(Int32)
Raises the Expanding event with ExpandingAndCollapsingEventArgs.
Declaration
protected bool RaiseExpandingEvent(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Represents the index. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if expanding event is not triggered else inverse of ExpandingAndCollapsingEventArgs.Cancel value. |
See Also
ShouldInvalidateOnChildAdded(View)
Override method to determine whether to invalidate on child added.
Declaration
protected override bool ShouldInvalidateOnChildAdded(View child)
Parameters
Type | Name | Description |
---|---|---|
Xamarin.Forms.View | child | Represents the View which is to be added. |
Returns
Type | Description |
---|---|
System.Boolean | Returns the boolean value accordingly. |
ShouldInvalidateOnChildRemoved(View)
Override method to determine whether to invalidate on child removed.
Declaration
protected override bool ShouldInvalidateOnChildRemoved(View child)
Parameters
Type | Name | Description |
---|---|---|
Xamarin.Forms.View | child | Represents the View which is to be removed. |
Returns
Type | Description |
---|---|
System.Boolean | Returns the boolean value accordingly. |
Events
Collapsed
This event occurs after an AccordionItem is collapsed when tapping on the Header.
Declaration
public event EventHandler<ExpandedAndCollapsedEventArgs> Collapsed
Event Type
Type |
---|
System.EventHandler<ExpandedAndCollapsedEventArgs> |
Remarks
The event handler receives an argument of type ExpandingAndCollapsingEventArgs containing data related to this event.
Examples
accordion.Collapsed += accordion_Collapsed;
private void accordion_Collapsed(object sender, Syncfusion.XForms.Accordion.ExpandedAndCollapsedEventArgs e)
{
var value = e.Index.ToString();
DisplayAlert("Index", value, "ok");
}
Collapsing
This event occurs while an AccordionItem is collapsing when tapping on the Header. It is possible to cancel the collapsing action using the System.ComponentModel.CancelEventArgs.Cancel property in the event args.
Declaration
public event EventHandler<ExpandingAndCollapsingEventArgs> Collapsing
Event Type
Type |
---|
System.EventHandler<ExpandingAndCollapsingEventArgs> |
Remarks
The user can control the expanding of content by using ExpandingAndCollapsingEventArgs of this event. If the Cancel property is set to true in the event's handler, the execution of the current event is cancelled.
Examples
accordion.Collapsing += Accordion_Collapsing;
private void Accordion_Collapsing(object sender, ExpandingAndCollapsingEventArgs e)
{
e.Cancel = true;
}
Expanded
This event occurs after an AccordionItem is expanded when tapping on the Header.
Declaration
public event EventHandler<ExpandedAndCollapsedEventArgs> Expanded
Event Type
Type |
---|
System.EventHandler<ExpandedAndCollapsedEventArgs> |
Remarks
The event handler receives an argument of type ExpandingAndCollapsingEventArgs containing data related to this event.
Examples
accordion.Expanded += Accordion_Expanded;
private void Accordion_Expanded(object sender, Syncfusion.XForms.Accordion.ExpandedAndCollapsedEventArgs e)
{
var value = e.Index.ToString();
DisplayAlert("Index", value, "ok");
}
Expanding
This event occurs while an AccordionItem is expanding when tapping on the Header. It is possible to cancel the expanding action using the System.ComponentModel.CancelEventArgs.Cancel property in the event args.
Declaration
public event EventHandler<ExpandingAndCollapsingEventArgs> Expanding
Event Type
Type |
---|
System.EventHandler<ExpandingAndCollapsingEventArgs> |
Remarks
The user can control the expanding of content by using ExpandingAndCollapsingEventArgs of this event. If the Cancel property is set to true in the event's handler, the execution of the current event is cancelled.
Examples
accordion.Expanding += Accordion_Expanding;
private void Accordion_Expanding(object sender, ExpandingAndCollapsingEventArgs e)
{
e.Cancel = true;
var value = e.Index.ToString();
DisplayAlert("Index",value, "ok");
}