Xamarin 在xmlns中找不到类型Page1

Xamarin 在xmlns中找不到类型Page1,xamarin,xamarin.forms,Xamarin,Xamarin.forms,我尝试实现shell页面,但在尝试编译时,在MasterDetailShell.xaml中出现以下错误。我认为无论路径如何,线路中都有问题 ContentTemplate="{DataTemplate local:Page1}" 错误: Type Page1 not found in xmlns MobileAppXamarinForms public partial class App : Application { public App() {

我尝试实现shell页面,但在尝试编译时,在MasterDetailShell.xaml中出现以下错误。我认为无论路径如何,线路中都有问题

ContentTemplate="{DataTemplate local:Page1}"
错误:

Type Page1 not found in xmlns   MobileAppXamarinForms   
public partial class App : Application
{
        public App()
        {
            InitializeComponent();
            MainPage = new MasterDetailShell();
        }
}
这是我的代码:

App.cs:

Type Page1 not found in xmlns   MobileAppXamarinForms   
public partial class App : Application
{
        public App()
        {
            InitializeComponent();
            MainPage = new MasterDetailShell();
        }
}
MasterDetailShell.cs

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MasterDetailShell : Shell
{
     public MasterDetailShell()
     {
         InitializeComponent();
     }
}
MasterDetailShell.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:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             x:Class="MobileAppXamarinForms.Views.MasterDetailShell.MasterDetailShell">

    <FlyoutItem Title="MyTabbApp"
                Shell.TabBarIsVisible="False"
                FlyoutDisplayOptions="AsMultipleItems">
        <ShellContent Title="Bears" Icon="" IsTabStop="True" ContentTemplate="{DataTemplate local:Page1}"></ShellContent>
        <ShellContent Title="Bears" Icon="" IsTabStop="True" ContentTemplate="{DataTemplate local:Page2}"></ShellContent>
    </FlyoutItem>

    <ShellContent Title="About" Icon="" ContentTemplate="{DataTemplate local:Page1}"></ShellContent>
</Shell>

文件位置:


您使用的是
本地
,但从未声明过

xmlns:local="using:ThisIsTheNamespaceForPage1"

要确定要使用哪个名称空间,请打开
Page.xaml.cs
并查看其
名称空间
声明

您的xaml需要定义
xmlns:local
太好了!你能告诉我Shell和MasterDetail有什么不同吗?对我来说也是一样。。