locked
How to create Menu with sub-menu in Hamburger Menu using listview RRS feed

  • Question

  • User371888 posted

    Hi, I have a menu in masterpage just like this

    I have create this menu using listview. Now i need to add sub-menu some of this menu items. how could i do this using listview. Just like below picture

    Thanks in advance.

    Sunday, July 19, 2020 7:42 AM

All replies

  • User254871 posted

    Use expandable list view

    Monday, July 20, 2020 6:57 AM
  • User382871 posted

    You could use the Grouping function of ListView to customize an expandable listView. Add a TapGestureRecogniser for the grouping title to add the click event. <ListView x:Name="listview" IsGroupingEnabled="True" > <ListView.ItemTemplate> <DataTemplate> <ViewCell> <StackLayout > <Label Text="{Binding Content}"/> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> <ListView.GroupHeaderTemplate> <DataTemplate> <ViewCell> <StackLayout> <Label Text="{Binding Title}"> <Label.GestureRecognizers> <TapGestureRecognizer .../> </Label.GestureRecognizers> </Label> </StackLayout> </ViewCell> </DataTemplate> </ListView.GroupHeaderTemplate> </ListView>

    You could google with the keyword as Xamarin.Forms - Expandable ListView With A Sub ListView MVVM Pattern to check the related tutorial.

    Monday, July 20, 2020 8:42 AM
  • User371888 posted

    @YelinZh Thanks for reply. I'll try it. But i have one question is, group titles do work like general list view items.

    Thursday, July 23, 2020 5:38 AM
  • User382871 posted

    But i have one question is, group titles do work like general list view items Yes, the listView doesn't provide these events for the grouping titles. But if you just want to use it for goup and clicking to expand the items, adding a tap gesture will help you to get that. If you are facing some issues while implementing, try to post the particular error with the corresponding codes here.

    Thursday, July 23, 2020 6:00 AM