我想在导航抽屉(主详细信息页面)中的列表视图中实现子项目。我实现了代码,但是没有用。请检查下面的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());
}
<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!这也可以。