Search code examples
c#listviewxamarin.formsscrollviewaccordion

Accordion inside list view does not start from top in Xamarin


<StackLayout>
     <Listview>
      <ListView.header>
       <StackLayout>
        <Grid>
         <accordion:AccordionView>
          <accordion:AccordionView.Children>
           <accordion:AccordionItemView>
            <accordion:AccordionItemView.ItemContent>
                  AccordionItemView ItemContent #1
            </accordion:AccordionItemView.ItemContent>
            <accordion:AccordionItemView.ItemContent>
                  AccordionItemView ItemContent #2
            </accordion:AccordionItemView.ItemContent>
           </accordion:AccordionItemView>
          </accordion:AccordionView.Children>
         </accordion:AccordionView>
        </Grid>
       </StackLayout>
      </ListView.header>
     </Listview>
</StackLayout>

I have a list view which has an accordion view inside it. I have set the accordion property KeepOnlyOneItemOpen="True", this works perfect. When I open my first accordion view and scroll it down and then when I tap and open my other accordion element, the first one closes but the one that I intend to open does not start from the top but instead it starts from where the list view's scroll stopped. I have not given any scroll view to my implementation as I have a list view. I HAVE NOT USED ANY SCROLLVIEW in my code.


Solution

  • Instead of using listview, scrollview made it more simpler. Hence removed listview and used scrollview inside grid and separate stacklayout.