当我处理 a 的 Tap 事件时,一切工作正常ListView
项目,但是当我在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());
}
仅在 iOS 中运行时才会出现此错误。
在 App.cs Rootpage(起始页)中给出如下所示
public App()
{
MainPage=new NavigationPage(new LoginPage());
}
现在,我们可以在全局中使用 PushAsyn()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)