Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Multi Level Accordian using ListView

$
0
0

I have a list of items. These items can each have a list of their own. At the most it can go eight levels deep. I'm trying to create an accordian style view using a listview. I'm struggling to find the best way to do this. My basic idea right now, (and I'm hoping someone has a better idea) is to have my embedded list, and when I need to change the view basically recursively go through my lists to build a single level list.

That is relatively easy. The tricky part comes in that when someone expands or collapses a level I don't know where that is in the original list, so I essentially have to recursively loop through it to find the one they clicked on and change the expanded property, before I can recursively loop through it again to rebuild my single layer list.

My other thought was to keep all the lists in an associative array, and when something is expanded or collapsed have the array name for each list be the parent id of that list. So first I would just grab the list with a parent id of 0. It's essentially the same recursive style loop to build my single layer list to display, but it will be much easier to find the item that was clicked as I won't have to recursively go through. I'll know the id of the item click and I can just grab its direct child list from the array of lists.

I don't know if any of that makes any sense. Any ideas or input is appreciated.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>