Xamarin.forms 在Xamarin表单中添加MasterDetails页面(命名空间已包含xx的定义)

Xamarin.forms 在Xamarin表单中添加MasterDetails页面(命名空间已包含xx的定义),xamarin.forms,Xamarin.forms,我用PCL选项创建了一个新的Xamarin表单项目,并添加了一个名为MainPage的masterdetailpage。一旦添加,我得到错误,说主页已经存在。 我正在使用VS2017和最新版本的Xamarin Error CS0101 The namespace '' already contains a definition for 'MainPage' \obj\Debug\xxxxxxMainPage.xaml.g.cs 非常感谢您的帮助。 谢谢 编辑: 这已经找到了答案。创

我用PCL选项创建了一个新的Xamarin表单项目,并添加了一个名为MainPage的masterdetailpage。一旦添加,我得到错误,说主页已经存在。 我正在使用VS2017和最新版本的Xamarin

Error   CS0101  The namespace '' already contains a definition for 'MainPage'   \obj\Debug\xxxxxxMainPage.xaml.g.cs
非常感谢您的帮助。 谢谢

编辑:


这已经找到了答案。

创建MasterDetailPage时出现了一些错误

让我们假设我已经创建了一个名为MyApp的项目和一个名为Page1的MasterDetailPage

1) 看起来,添加的页面具有错误的命名空间。因此,在添加的页面上更改名称空间

Visual Studio添加到新页面命名空间MyApp.Page1

    Page1.xaml.cs - change the Namespace to be just MyApp
   Page1Detail.xaml.cs - Change the namespace to be just MyApp
   Page1Master.xaml.cs - Change the namespace to be just MyApp
   Page1MenuItem.cs - Change the namespace to "MyApp"
2) 我还注意到,在Page1Master.xaml.cs中,它错误地引用了MenuItems

    It says Page1MenuItems = new ObservableCollection...
Change that to be just
MenuItems = new ObservableCollection...
这对我很管用


希望能有所帮助

创建MasterDetailPage时出现了一些错误

让我们假设我已经创建了一个名为MyApp的项目和一个名为Page1的MasterDetailPage

1) 看起来,添加的页面具有错误的命名空间。因此,在添加的页面上更改名称空间

Visual Studio添加到新页面命名空间MyApp.Page1

    Page1.xaml.cs - change the Namespace to be just MyApp
   Page1Detail.xaml.cs - Change the namespace to be just MyApp
   Page1Master.xaml.cs - Change the namespace to be just MyApp
   Page1MenuItem.cs - Change the namespace to "MyApp"
2) 我还注意到,在Page1Master.xaml.cs中,它错误地引用了MenuItems

    It says Page1MenuItems = new ObservableCollection...
Change that to be just
MenuItems = new ObservableCollection...
这对我很管用


希望有帮助

奇怪,可能是VS2017出现了问题,或者您在项目中创建了两个名为
MainPage
的对象。我不确定是否存在同名的类。它为xaml生成了一个带有.g.cs的类,该类也有部分类声明。奇怪的是,要么VS2017出现了问题,要么您在项目中创建了两个名为
MainPage
的对象。我不确定是否有同名的类。它为xaml生成了一个带有.g.cs的类,该类也有部分类声明。谢谢:)这是来救我的。谢谢:)