我得到了例外
Java.Lang.IllegalArgumentException: Only TabItem instances can be added to TabLayout
这是我的 XAML 代码-
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:RestaurantApp"
x:Class="RestaurantApp.SearchTabbedPage">
<!--Pages can be added as references or inline-->
<TabbedPage.Children>
<NavigationPage Title="VENDOR NAME">
<x:Arguments>
<pages:TabbedPageExampleTab1 />
</x:Arguments>
</NavigationPage>
<NavigationPage Title="PRODUCT/SERVICE">
<x:Arguments>
<pages:TabbedPageExampleTab2 />
</x:Arguments>
</NavigationPage>
</TabbedPage.Children>
</TabbedPage>
这是我的代码背后的代码
namespace RestaurantApp
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class SearchTabbedPage : TabbedPage
{
public SearchTabbedPage ()
{
InitializeComponent();
}
}
}
这是 app.xaml.cs 代码
public App()
{
InitializeComponent();
MainPage = new SearchTabbedPage();
//};
}
这是 TabbedPageExampleTab1 的 xaml 代码
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="RestaurantApp.TabbedPageExampleTab1">
<ContentPage.Content>
<StackLayout>
<Label Text="Hello. I am Judson" Margin="5" />
<Label Text="You are on Tab one"></Label>
<BoxView VerticalOptions="FillAndExpand" Color="Silver"></BoxView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
这是后面的代码
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class TabbedPageExampleTab1 : ContentPage
{
public TabbedPageExampleTab1 ()
{
InitializeComponent ();
}
}
TabbedPageExampleTab2 也遵循相同的代码。
这是我需要的 UI
我不知道为什么我会得到这个例外。有什么建议么。 这是项目压缩文件的谷歌驱动器链接