当我处理 ListView
项的 Tap 事件时,一切都正常工作,但是当我在 TabbedPage
中使用它时,会显示异常,请提供解决此问题的方案,谢谢。
异常:在 iOS 上全局不支持 PushAsync,请使用 NavigationPage。
以下是 Xaml 代码:
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:NavTest" x:Class="NavTest.NavTestPage" Title="Home">
<ContentPage.Content>
<StackLayout Orientation="Vertical" VerticalOptions="Center">
<Label Text="Welcome to Xamarin Forms!" VerticalOptions="Center" HorizontalOptions="Center" />
<!--<Button Text="Go to " BackgroundColor="Lime" VerticalOptions="Center" Clicked="Handle_Clicked" >
</Button>-->
<ListView x:Name="myListView" ItemSelected="Handle_ItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Label Text="{Binding}" VerticalOptions="Center" HorizontalOptions="Center" />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
这里是OnClick处理程序:
async void Handle_Clicked(object sender, System.EventArgs e)
{
await Navigation.PushAsync(new Page1());
}