Xamarin-如何在ListView中打开新的ContentPage?
我有一个来自我的web服务的列表,我会这样显示它:Xamarin-如何在ListView中打开新的ContentPage?,xamarin,xamarin.forms,xamarin.forms.listview,Xamarin,Xamarin.forms,Xamarin.forms.listview,我有一个来自我的web服务的列表,我会这样显示它: <StackLayout HorizontalOptions="FillAndExpand"> <ListView x:Name="curso" ItemSelected="CursoView_ItemSelected"> <ListView.ItemTemplate> <DataTemplate> <ViewC
<StackLayout HorizontalOptions="FillAndExpand">
<ListView x:Name="curso" ItemSelected="CursoView_ItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal">
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand">
<Label StyleClass="Header" Text="{Binding name}" />
</StackLayout>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
现在我想点击一个项目并打开一个新的内容页面这是我的问题我的当前页面不是导航页面你可以简单地用一个新页面替换App.MainPage,但是用户将无法向后导航如果您对使用NavigationPage不感兴趣,您也可以以模式显示新页面。但是现在我的列表中有3项。我如何让他们根据用户单击的项目推送新页面?使用e.itemselected这是我的问题我的当前页面不是导航页面您可以简单地用新页面替换App.MainPage,但是用户将无法向后导航如果您对使用NavigationPage不感兴趣,您也可以以模式显示新页面。但是现在我的列表中有3项。如何让他们根据用户单击的项目推送新页面?请使用e.ItemSelected
public void CursoView_ItemSelected(object sender, ItemSelectedEventArgs e)
{
// this assumes your current page is already contained in a NavigationPage
Navigation.PushAsync(new MyNextPage());
}