使用主细节页面的导航抽屉列表视图子菜单

问题描述 投票:0回答:1

我想在导航抽屉(主详细信息页面)中的列表视图中实现子项目。我实现了代码,但是没有用。请检查下面的Github链接以获取我的代码。

https://github.com/priyam1996/NavigationSubMenuProject

public MainPage()
        {
            InitializeComponent();
            NavigationPage.SetHasBackButton(this, false);
            NavigationPage.SetHasNavigationBar(this, false);

            HotelsGroupViewModel viewModel = new HotelsGroupViewModel();
            HotelsList.ItemsSource = viewModel.Items;

            this.IsPresented = false;
            Detail = new NavigationPage(new Dashboard());
        }
listview xamarin.forms navigation-drawer submenu
1个回答
0
投票
<StackLayout x:Name="hotelStack" Padding="1,0,1,0" >
            <ListView
                x:Name="HotelsList"
                BackgroundColor="White"
                IsGroupingEnabled="True"
                IsPullToRefreshEnabled="true"
                IsRefreshing="{Binding IsBusy, Mode=OneWay}"
                ItemsSource="{Binding Items}"
                RefreshCommand="{Binding LoadHotelsCommand}"
                >
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal"  VerticalOptions="Center">
                                    <Label
                                        VerticalOptions="Center"
                                        FontAttributes="Bold"
                                        FontSize="Medium"
                                        Text="{Binding .RoomName}"
                                        TextColor="Black"
                                        VerticalTextAlignment="Center" />                                  
                            </StackLayout>                                   
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
                <ListView.GroupHeaderTemplate>
                    <DataTemplate>
                        <ViewCell>
                           <Grid >
                               <Label
                                            FontAttributes="Bold"
                                            FontSize="Small"
                                            Text="{Binding Name}"
                                            TextColor="Gray"
                                            VerticalTextAlignment="Center" />
                                <Image x:Name="ImgA" Source="{Binding StateIcon}"  Margin="0,0,5,0" HeightRequest="20" WidthRequest="20" HorizontalOptions="End"/>
                                <Grid.GestureRecognizers>
                                    <TapGestureRecognizer Command="{Binding Source={x:Reference currentPage}, Path=BindingContext.RefreshItemsCommand}"  NumberOfTapsRequired="1" CommandParameter="{Binding .}"/>
                                </Grid.GestureRecognizers>
                            </Grid>                               
                        </ViewCell>
                    </DataTemplate>
                </ListView.GroupHeaderTemplate>
            </ListView>
        </StackLayout>

单击here!这也可以。

© www.soinside.com 2019 - 2024. All rights reserved.