Visual studio Xamarin.Forms ViewCell/Visual Studio 2019-“;部分声明';someType';不得指定不同的基类“;

Visual studio Xamarin.Forms ViewCell/Visual Studio 2019-“;部分声明';someType';不得指定不同的基类“;,visual-studio,xamarin.forms,visual-studio-2019,xamarin.forms.listview,Visual Studio,Xamarin.forms,Visual Studio 2019,Xamarin.forms.listview,在我的Xamarin.Forms项目中,我试图创建一个可重用的ViewCell。但是,我不明白为什么在使用VS提供的模板创建ViewCell XAML和CS文件时,由于以下错误,它将无法编译: “DateViewCell的部分声明不能指定不同的基类” 这个错误在我创建文件的第二次出现(正如你在下面的代码中看到的,我还没有添加任何代码,这都是样板文件),并且我有一个功能完整的Xamarin.Forms项目,如果我删除扩展名,它的编译就不会出现问题 DateViewCell.xaml: <?x

在我的Xamarin.Forms项目中,我试图创建一个可重用的ViewCell。但是,我不明白为什么在使用VS提供的模板创建ViewCell XAML和CS文件时,由于以下错误,它将无法编译:

“DateViewCell的部分声明不能指定不同的基类”

这个错误在我创建文件的第二次出现(正如你在下面的代码中看到的,我还没有添加任何代码,这都是样板文件),并且我有一个功能完整的Xamarin.Forms项目,如果我删除扩展名,它的编译就不会出现问题

DateViewCell.xaml:

<?xml version="1.0" encoding="UTF-8"?>
<ViewCell 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="HelloWorld.Extensions.DateViewCell">
  <ViewCell.View>
      <StackLayout>
          <Label Text="Hello Xamarin.Forms!" />
      </StackLayout>
  </ViewCell.View>
</ViewCell>
DateViewCell.xaml.g.cs:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

[assembly: global::Xamarin.Forms.Xaml.XamlResourceIdAttribute("HelloWorld.Extensions.DateViewCell.xaml", "Extensions/DateViewCell.xaml", typeof(global::HelloWorld.Extensions.DateViewCell))]

namespace HelloWorld.Extensions {


    [global::Xamarin.Forms.Xaml.XamlFilePathAttribute("Extensions\\DateViewCell.xaml")]
    public partial class DateViewCell : global::Xamarin.Forms.ViewCell {

        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "2.0.0.0")]
        private void InitializeComponent() {
            global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(DateViewCell));
        }
    }
}
//------------------------------------------------------------------------------
// 
//这段代码是由一个工具生成的。
//运行时版本:4.0.30319.42000
//
//对此文件的更改可能会导致不正确的行为,如果
//重新生成代码。
// 
//------------------------------------------------------------------------------
[程序集:global::Xamarin.Forms.Xaml.XamlResourceIdAttribute(“HelloWorld.Extensions.DateViewCell.Xaml”,“Extensions/DateViewCell.Xaml”,typeof(global::HelloWorld.Extensions.DateViewCell))]
命名空间HelloWorld.Extensions{
[全局::Xamarin.Forms.Xaml.XamlFilePathAttribute(“Extensions\\DateViewCell.Xaml”)]
公共部分类DateViewCell:global::Xamarin.Forms.ViewCell{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(“Xamarin.Forms.Build.Tasks.XamlG”,“2.0.0.0”)]
私有void InitializeComponent(){
global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(这个,typeof(DateViewCell));
}
}
}
这里有点死胡同。我试着手动创建这个“DateViewCell”扩展名,但得到的错误与让VS为我创建文件时的错误相同。我开始怀疑这是否是Xamarin的一个bug


有人有什么建议吗?我能找到的引用这个错误的文章并没有真正应用,我也没有更好的方法来搜索这个。。。谢谢大家。

这只会在您使用模板时发生还是总是发生?如果您完全限定了名称,它会起作用吗?例如,在课堂上使用“Xamarin.Forms.ViewCell”declaration@Jason! 就这样。。。哦,我的上帝。。。证明我坐在这张桌子上太久了。非常感谢。
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

[assembly: global::Xamarin.Forms.Xaml.XamlResourceIdAttribute("HelloWorld.Extensions.DateViewCell.xaml", "Extensions/DateViewCell.xaml", typeof(global::HelloWorld.Extensions.DateViewCell))]

namespace HelloWorld.Extensions {


    [global::Xamarin.Forms.Xaml.XamlFilePathAttribute("Extensions\\DateViewCell.xaml")]
    public partial class DateViewCell : global::Xamarin.Forms.ViewCell {

        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "2.0.0.0")]
        private void InitializeComponent() {
            global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(DateViewCell));
        }
    }
}