SFListView (Accordion view) not displaying sub items when item is tapped.

Hi,

I am developing a prototype mobile application and I have found that Syncfusion's controls are very easy to use. I am facing an issue with the accordion list in my mobile application where the sub items are not displaying when the item in the list is tapped. I have attached my solution to this thread and a screenshot of the issue. My application will work as follows:

1. App is opened and the user will login. (MainPage.xaml)
2. If login succeeds, a second screen is displayed showing data using Syncfusion controls (SfTabView, SfCircularGauge and SFListView). (AgentData.xaml)

I have installed the Accordion sample on my phone and there is no issue.Can you let me know what I need to do to get the Listview working correctly?

Best regards,

Pete

Attachment: Screenshot_8081f99a.zip

1 Reply

JN Jayaleshwari N Syncfusion Team November 2, 2018 09:24 AM UTC

Hi Pete, 
 
Thanks for Contacting Syncfusion Support. 
 
We have checked the reported query “SFListView (Accordion view) not displaying sub items when item is tapped.” from our side. You can achieve your requirement using RefreshListViewItem method when tap on the item. 
 
Code snippet C#: Refreshing the tapped item  
 
private void ListView_ItemTapped(object sender, Syncfusion.ListView.XForms.ItemTappedEventArgs e) 
{ 
    if (tappedItem == null) 
    { 
        // Expands when tap on the item at first. 
        (e.ItemData as Contact).IsVisible = true; 
        tappedItem = e.ItemData as Contact; 
    } 
    else 
    { 
        if (AccordionViewModel.ContactsInfo.Contains(tappedItem) && tappedItem.IsVisible) 
        { 
            // Collapse when tap on the expanded item. 
            var previousitemIndex = listview.DataSource.DisplayItems.IndexOf(tappedItem); 
            AccordionViewModel.ContactsInfo.FirstOrDefault(x => x.ContactName == tappedItem.ContactName).IsVisible = false; 
            Device.BeginInvokeOnMainThread(() => { listview.RefreshListViewItem(previousitemIndex, previousitemIndex, false); }); 
        } 
        if (e.ItemData as Contact != tappedItem) 
        { 
            // Expands when tap on the another item. 
            tappedItem = e.ItemData as Contact; 
            AccordionViewModel.ContactsInfo.FirstOrDefault(x => x.ContactName == tappedItem.ContactName).IsVisible = true; 
        } 
        else 
            tappedItem = null; 
    } 
    if (e.ItemData != null) 
        Device.BeginInvokeOnMainThread(() => { listview.RefreshListViewItem(listview.DataSource.DisplayItems.IndexOf(e.ItemData), listview.DataSource.DisplayItems.IndexOf(e.ItemData), false); }); 
} 
 
We have attached the sample for your reference and you can download the same from the following location. 
 
We will update this code snippet in our UG also in shortly. Please let us know if you would require further assistance. 
 
Regards, 
Jayaleshwari N. 


Loader.
Up arrow icon