首页 > 解决方案 > 为什么 xaml 选项卡式页面属性 local 在这种情况下不起作用?

问题描述

我有一个非常简单的 xaml 代码,但属性 local:Page 根本不起作用,当我键入“local”时,它会加下划线,就好像有错误一样。

MainPage.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:local="clr-namespace:Solution;assembly=Solution"
             x:Class="Solution.MainPage">

    <local:Listar Title="XXXX" />

</TabbedPage>

Listar.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:Solution;assembly=Solution"
             x:Class="Solution.Listar">
    <ContentPage.Content>
        <StackLayout>
            <Label Text="Welcome to Xamarin.Forms!"
                VerticalOptions="CenterAndExpand" 
                HorizontalOptions="CenterAndExpand" />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

标签: xamarintabstabbedpage

解决方案


TabbedPage 必须包含子页面。

<TabbedPage.Children>

        <local:Listar Title="XXX"/>

</TabbedPage.Children>

推荐阅读