SfListView with accordion... how to associate an action to expandable items

Hi, 
i tried the example of sflistview with accordion and the example works but I don't know how to associate an action (for example navigate to another page) where the user click on a expandable item (the items inserted into the grid expandable). Do you have a complete example about this?

thank you!
Michele

1 Reply

CS Chandrasekar Sampathkumar Syncfusion Team March 15, 2020 07:51 AM UTC

Hi Michele, 
 
Thank you using Syncfusion products. 
 
We have checked the reported query from our end. We suggest you to use GestureRecognizers for Accordion content to achieve your requirement. Please refer following code snippets for further reference, 
 
Code Snippet Xaml: GestureRecognizer for Accordion content 
 
<sflistview:SfListView x:Name="listView" AutoFitMode="DynamicHeight" 
                        ItemsSource="{Binding ContactsInfo}" > 
    <sflistview:SfListView.ItemTemplate> 
        <DataTemplate> 
            <Grid > 
                <syncfusion:SfAccordion x:Name="Accordion"> 
                    <syncfusion:SfAccordion.Items> 
                        <syncfusion:AccordionItem > 
                            <syncfusion:AccordionItem.Header > 
                                <Grid BackgroundColor="LightGray"> 
                                    <Label Text="{Binding ContactName}"/> 
                                </Grid> 
                            </syncfusion:AccordionItem.Header> 
 
                            <syncfusion:AccordionItem.Content> 
                                <Grid> 
                                    <Grid.GestureRecognizers> 
                                        <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" /> 
                                    </Grid.GestureRecognizers> 
                                    <Label Text="{Binding ContactAddress}"/> 
                                </Grid> 
                            </syncfusion:AccordionItem.Content> 
                        </syncfusion:AccordionItem> 
                    </syncfusion:SfAccordion.Items> 
                </syncfusion:SfAccordion> 
            </Grid> 
        </DataTemplate> 
    </sflistview:SfListView.ItemTemplate> 
</sflistview:SfListView> 
            
 
Code Snippet C#: GestureRecognizer for navigation 
 
private void TapGestureRecognizer_Tapped(object sender, EventArgs e) 
{ 
    App.Current.MainPage.Navigation.PushAsync(new ContactDetails()); 
} 
 
Please let us know if you need further assistance. 
 
Regards, 
Chandrasekar Sampathkumar 


Loader.
Up arrow icon