C# 指定的Xamarin TabbedPage转换无效

C# 指定的Xamarin TabbedPage转换无效,c#,xaml,xamarin.forms,tabbedpage,xamarin.forms.shell,C#,Xaml,Xamarin.forms,Tabbedpage,Xamarin.forms.shell,我的AppShell中有一个选项卡栏,它有五个选项卡 其中三个选项卡是ContentPages,而另外两个是TabbedPages。所有三个带有ContentPages的选项卡都可以正常打开,但带有TabbedPages的两个选项卡显示“指定的强制转换无效”错误 AppShell.xaml <?xml version="1.0" encoding="UTF-8"?> <Shell xmlns="http://xamarin.co

我的AppShell中有一个选项卡栏,它有五个选项卡

其中三个选项卡是ContentPages,而另外两个是TabbedPages。所有三个带有ContentPages的选项卡都可以正常打开,但带有TabbedPages的两个选项卡显示“指定的强制转换无效”错误

AppShell.xaml

<?xml version="1.0" encoding="UTF-8"?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms" 
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
       xmlns:local="clr-namespace:ReleaseVerificationAndroid.Views"
       Title="ReleaseVerificationAndroid"
       x:Class="ReleaseVerificationAndroid.AppShell">

    <TabBar x:Name="MainTab" Route="HomePage">
        <Tab Title="Home" Icon="icon_home.png">
            <ShellContent Route="HomePage" ContentTemplate="{DataTemplate local:HomePage}"/>
        </Tab>
        <Tab Title="Fingerprints" Icon="icon_fingerprint.png" IsVisible="True">
            <ShellContent Route="FingerprintPage" ContentTemplate="{DataTemplate local:FingerprintPage}"/>
        </Tab>
        <Tab Title="Mugshots" Icon="icon_mugshot.png" IsVisible="True">
            <ShellContent Route="MugshotPage" ContentTemplate="{DataTemplate local:MugshotPage}"/>
        </Tab>
        <Tab Title="Irises" Icon="icon_iris.png" IsVisible="True">
            <ShellContent Route="IrisPage" ContentTemplate="{DataTemplate local:IrisPage}"/>
        </Tab>
        <Tab Title="Result" Icon="icon_feed.png">
            <ShellContent Route="ResultPage" ContentTemplate="{DataTemplate local:ResultPage}"/>
        </Tab>
    </TabBar>

</Shell>

IrisPage.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:vm="clr-namespace:ReleaseVerificationAndroid.ViewModels"
             x:Class="ReleaseVerificationAndroid.Views.LeftIrisPage">
    <ContentPage.BindingContext>
        <vm:LeftIrisViewModel />
    </ContentPage.BindingContext>
    <ContentPage.Content>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="75"/>
                <RowDefinition Height="*" />
                <RowDefinition Height="60"/>
            </Grid.RowDefinitions>
            <ContentView Grid.Row="0" Padding="0,10,0,0" VerticalOptions="FillAndExpand">
                <Image Source="mentalix_logo.png" VerticalOptions="Center" HeightRequest="48" />
            </ContentView>
            <Frame Grid.Row="1" Margin="10,0,10,10" BackgroundColor="Transparent"
                   BorderColor="#333333"
                   CornerRadius="0"
                   HasShadow="True">
                <ContentView VerticalOptions="CenterAndExpand">
                    <Image VerticalOptions="Center" HeightRequest="500" />
                </ContentView>
            </Frame>
            <Grid Grid.Row="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Button Grid.Column="0" Margin="10,0,10,12.5" Text="Scan"
                        Command="{Binding RescanLeftIrisCmd}"
                        BackgroundColor="{StaticResource PrimaryButton}"
                        TextColor="White" />

                <Button Grid.Column="1" Margin="2.5,0,10,12.5" Text="Clear"
                        Command="{Binding ClearLeftIrisCmd}"
                        BackgroundColor="{StaticResource Primary}"
                        TextColor="White" />
            </Grid>

        </Grid>
    </ContentPage.Content>
</ContentPage>

由于您的主要目标是同时嵌套选项卡式页面和我们的eshell,您可能会对Xamarin社区工具包包中的
选项卡式视图感兴趣。目前,您可以随意嵌套和延迟加载,但目前它只支持视图而不支持页面。将来它可能还支持页面类型,如果可能的话,您可以尝试将页面转换为
ContentView

文档

回购

相关问题

为什么要在Shell Tabbar/Tab旁边使用选项卡式页面?我正在尝试创建嵌套的选项卡式层次结构。五个主要标签是主页、指纹、照片、虹膜和结果。我想为指纹和虹膜添加两个嵌套选项卡(分别为左和右)。您不能嵌套选项卡页面。请确保我们位于同一页面上,我不是在选项卡页面中嵌套选项卡页面,而是在选项卡栏内容页面中添加选项卡页面。如果不可能,有什么替代方案?
<?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:vm="clr-namespace:ReleaseVerificationAndroid.ViewModels"
             x:Class="ReleaseVerificationAndroid.Views.LeftIrisPage">
    <ContentPage.BindingContext>
        <vm:LeftIrisViewModel />
    </ContentPage.BindingContext>
    <ContentPage.Content>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="75"/>
                <RowDefinition Height="*" />
                <RowDefinition Height="60"/>
            </Grid.RowDefinitions>
            <ContentView Grid.Row="0" Padding="0,10,0,0" VerticalOptions="FillAndExpand">
                <Image Source="mentalix_logo.png" VerticalOptions="Center" HeightRequest="48" />
            </ContentView>
            <Frame Grid.Row="1" Margin="10,0,10,10" BackgroundColor="Transparent"
                   BorderColor="#333333"
                   CornerRadius="0"
                   HasShadow="True">
                <ContentView VerticalOptions="CenterAndExpand">
                    <Image VerticalOptions="Center" HeightRequest="500" />
                </ContentView>
            </Frame>
            <Grid Grid.Row="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Button Grid.Column="0" Margin="10,0,10,12.5" Text="Scan"
                        Command="{Binding RescanLeftIrisCmd}"
                        BackgroundColor="{StaticResource PrimaryButton}"
                        TextColor="White" />

                <Button Grid.Column="1" Margin="2.5,0,10,12.5" Text="Clear"
                        Command="{Binding ClearLeftIrisCmd}"
                        BackgroundColor="{StaticResource Primary}"
                        TextColor="White" />
            </Grid>

        </Grid>
    </ContentPage.Content>
</ContentPage>