Category / Section
How to retrieve the expanding Accordion item index in Xamarin.Forms (SfAccordion)?
1 min read
You can get the index of AccordionItem when expanding in Xamarin.Forms SfAccordion.
C#
You can get the index from the ExpandingAndCollapsingEventArgs of the Expanding event.
namespace AccordionXamarin.Behavior { public class Behavior : Behavior<SfAccordion> { SfAccordion Accordion; protected override void OnAttachedTo(SfAccordion bindable) { Accordion = bindable; Accordion.Expanding += Accordion_Expanding; base.OnAttachedTo(bindable); } private void Accordion_Expanding(object sender, ExpandingAndCollapsingEventArgs e) { App.Current.MainPage.DisplayAlert("", "AccordionItem expanded at index " + e.Index, "Ok"); } } }